You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I mean that let's assumme that we have inherited from Proxy and created some hooks for example on getattr. And we wanna these hooks work only for unwrapped object.
For example we wanna collect every set attr into a dict and then apply it when it is set. So we create a dict, add into the factory a loop applying it, add into setattr impl the stuff populating it.
But when the factory is triggered, we need to access the original object. So we disable this behaviour in our proxy, but ... our python code is still executed.
Proxy has done its purpose, but we still have overhead.
So, I wonder if it is possible to get all the refs to the Proxy from the interpreter internals and replace them with the refs to the constructed object.
The text was updated successfully, but these errors were encountered:
KOLANICH
changed the title
Is it possibke to replace a Proxy object with its __wrapped__
Is it possible to replace a Proxy object with its __wrapped__
Nov 22, 2018
Seems horrendously unsafe to mess with raw memory. If overhead is really a problem for you then fork this project and add the _delayed stuff in the cext implementation.
I mean that let's assumme that we have inherited from Proxy and created some hooks for example on
getattr
. And we wanna these hooks work only for unwrapped object.For example we wanna collect every set attr into a dict and then apply it when it is set. So we create a dict, add into the factory a loop applying it, add into setattr impl the stuff populating it.
But when the factory is triggered, we need to access the original object. So we disable this behaviour in our proxy, but ... our python code is still executed.
Proxy has done its purpose, but we still have overhead.
So, I wonder if it is possible to get all the refs to the Proxy from the interpreter internals and replace them with the refs to the constructed object.
https://benkurtovic.com/2015/01/28/python-object-replacement.html
The text was updated successfully, but these errors were encountered: