-
-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why is this not part of wrapt? #22
Comments
Didn't occur to me that they would have the same scope (wrapt is for decorators, LOP is simply a call-on-first-use proxy) or that @GrahamDumpleton would like to maintain this. It's a big lump of code (can't really have same C code doing both kinds of wrappings without loosing perf) + a big lump of tests after all ... Do you want to make the contribution to wrapt or why do you ask this question? |
I don't have time to do that right now, and was mostly just asking out of curiosity. I can't help but feel it would be better if you were both maintaining the same package, two maintainers is better than one after all. Reduces bus-factor. It doesn't look like wrapt is for decorators to me? Their object-proxy is pretty useful, and I don't really understand why this object proxy isn't an optional-extension to that object proxy. Or rather, why that object proxy isn't an optional extension to this one, that loads on startup. Lazy-object-proxies seem like a superset of object-proxies. Being able to use Not very important, and probably not worth the effort, but figured I'd ask you to take a look. |
The wrapt package was originally intended for monkey patching, so the transparent object proxy was the main purpose of the library. It just happens that the object proxy is what you need to implement decorators properly. If the package was only advertised as being for monkey patching, no one would have looked at it, so from marketing perspective has been better to push it as a decorator package. Is the only think this package does differently is allowing for lazy creation of the wrapped object? Doing that in C code doesn't need to add any overhead. Avoiding overhead in Python will just need a bit of magic which I can half see in my head how to do, so just need to try it. I don't understand the comments about Did we already have an issue in wrapt GitHub for adding lazy construction of wrapped object? I remember us discussing this before but I can't find it. Maybe it was in email. |
My comments on |
FWIW, I would probably implement it so that as long as you wrap the factory function in a special type so it can be unique identified, that I overload the passed in wrapped argument. There is a similar construct used in the decorator when supplying an adapter definition to change the type specification.
Which is used as:
The actual code then has a check:
In the case we are talking about would use it as:
IOW, based on see special factory type, change what happens internally such that flagged that need to do lazy setting of wrapped object first time it is required. So you don't need a special type of the lazy case, would be part of the one proxy class implementation. |
It seems like this is the kind of thing that would be better as an upstream contribution to wrapt, and not as it's own module.
The text was updated successfully, but these errors were encountered: