-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Add __slots__ to pl.Expr and pl.LazyFrame #13198
Comments
What will that do? |
|
Well, then registration of namespace would be better handled by using descriptors. Like this. Will experiment on this once I get to PR. class Namespace:
def __get__(self, obj, objtype=None):
return "FooNamespace"
class Foo:
__slots__ = ("_bar",)
Foo.namespace = Namespace()
instance = Foo()
print(instance.namespace) # prints FooNamespace
print(Foo.namespace) # prints FooNamespace too |
Having |
NameSpace class that wraps plugins is already is a descriptor. And it seems like it's registered on classes in _create_namespace, and that should not interact with @mcrumiller Am I missing something here? |
@Object905 if it works, go for it! I may have done something incorrect, and this was a while ago so I don't recall the details. Are you talking about adding |
Yes. Builtin namespaces, like str, list, etc also good candidates. |
@Object905 what do you recommend for adding attributes to instances, given that after this change one can't use |
@knl I was just about to make a feature request for an empty |
Description
Profiled count of created pl.Expr and pl.LazyFrame in my use case (graphQL api on top of polars).
Found that one of the heaviest queries creates pl.Expr around 3k times and pl.LazyFrame around 1k times.
Tried to "monkey patch" adding slots on them directly in .venv and found that it seems to be working ok.
Will follow up with PR later.
The text was updated successfully, but these errors were encountered: