mirror of https://github.com/pyodide/pyodide.git
Don't pyimport repr multiple times
This commit is contained in:
parent
3831cf86fc
commit
7b6053ed13
|
@ -75,16 +75,6 @@ var languagePluginLoader = new Promise((resolve, reject) => {
|
|||
return promise;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Callable Python object shim
|
||||
let makeCallableProxy = (obj) => {
|
||||
var clone = obj.clone();
|
||||
function callProxy(args) {
|
||||
return clone.call(Array.from(arguments), {});
|
||||
};
|
||||
return callProxy;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Loading Pyodide
|
||||
let wasmURL = `${baseURL}pyodide.asm.wasm`;
|
||||
|
@ -112,7 +102,6 @@ var languagePluginLoader = new Promise((resolve, reject) => {
|
|||
script.onload = () => {
|
||||
window.pyodide = pyodide(Module);
|
||||
window.pyodide.loadPackage = loadPackage;
|
||||
window.pyodide.makeCallableProxy = makeCallableProxy;
|
||||
};
|
||||
document.head.appendChild(script);
|
||||
};
|
||||
|
|
|
@ -127,9 +127,10 @@ EM_JS(int, pyproxy_init, (), {
|
|||
get: function (jsobj, jskey) {
|
||||
if (jskey === 'toString') {
|
||||
return function() {
|
||||
// TODO: Cache repr
|
||||
var repr = pyodide.pyimport('repr');
|
||||
return repr(jsobj);
|
||||
if (window.pyodide.repr === undefined) {
|
||||
window.pyodide.repr = window.pyodide.pyimport('repr');
|
||||
}
|
||||
return window.pyodide.repr(jsobj);
|
||||
}
|
||||
} else if (jskey === '$$') {
|
||||
return jsobj['$$'];
|
||||
|
|
Loading…
Reference in New Issue