diff options
author | Damien George <damien@micropython.org> | 2025-07-21 23:41:16 +1000 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2025-07-31 11:40:50 +1000 |
commit | ffa98cb0143c43af9f4c61142784a08a19f660c5 (patch) | |
tree | e3a35a5c673de889773948b410f3c6e8b3d662ca /docs/esp8266/tutorial | |
parent | 813f0c1cb9460502d0d8de24106f7ee8cc0723ee (diff) |
webassembly/proxy_js: Reuse JsProxy ref if object matches.
This reduces memory use by reusing objects, and improves identity/equality
relationships of JavaScript objects on the Python side.
In 77bd8fe5b80b0e7e02cdb6b4272c401ae3dca638 PyProxy's were reused when the
same Python object was proxied across to JavaScript. This commit does the
same thing but for JsProxy's going from JS to Python. If an existing
JsProxy reference exists for the JS object about to be proxied across, then
it's reused.
This helps reduce the number of alive objects (memory use), and, more
importantly, improves equality relationships of JavaScript objects on the
Python side. Eg we now get, on the Python side:
import js
print(js.Object == js.Object)
that prints True. Previously it was False.
Note that this change does not make identity work with `is`, for example
`js.Object is js.Object` is actually False. With more work that could be
made True but for now we leave that as-is.
The behaviour with this commit matches Pyodide semantics.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'docs/esp8266/tutorial')
0 files changed, 0 insertions, 0 deletions