-
Notifications
You must be signed in to change notification settings - Fork 46
v0.4.0 #308
zollqir
announced in
Announcements
v0.4.0
#308
PythonMonkey v0.4.0
- fixed a bug where methods called on proxied JS objects would use
globalThisfor the value ofthis - implemented proxying of arbitrary python objects in JavaScript, like so:
import pythonmonkey as pm class Counter: def __init__(self): self.count = 0 def increment(self): self.count = self.count + 1 pm.eval(""" (pyObject) => { console.log(pyObject.count); // 0 pyObject.increment(); console.log(pyObject.count); // 1 } """)(pyObject)
- implemented a new type called JSMethodProxy, which can be used to implement methods on python objects in JavaScript, like so:
import pythonmonkey as pm jsFunc = pm.eval("(function() { this.count++; })") class Counter: def __init__(self): self.count = 0 self.increment = pm.JSMethodProxy(jsFunc, counter) counter = Counter() print(counter.count) # 0 counter.increment() print(counter.count) # 1
- various garbage collection optimizations
- various memory leak fixes
- implemented complete cross-language stack traces
pm.evalcan now accept a file object as its first argument (such as an object returned by theopen()python built-in), which is expected to be a javascript file- when calling
pm.require(or other requires created bypm.createRequire), .py CommonJS modules now have precedence over .js modules when there is a namespace collision setTimeoutnow returns a Node.js-styleTimeoutclass for the timeout id, with.ref()and.unref()methods- implemented
XMLHttpRequest.withCredentials - implemented
"json"support forXMLHttpRequest.responseType - implemented remaining standard
consolemethods
This discussion was created from the release v0.4.0.
All reactions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment