-
Notifications
You must be signed in to change notification settings - Fork 5
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
Is it possible to lazy load the repr handlers? #16
Comments
I am interested in this (#3) but I don't know the best way to do it or how easy it would be. Happy to accept a PR. Since it seems like it requires an import hook it could be a Python 3 only enhancement. |
I think it would be helpful to write down what you have in mind about import hooks, and we can see if somebody will have time to work on this. |
I'm imagining an import hook that is triggered whenever a module name that was registered with
What did you have in mind? |
I was more thinking of doing reigsitering when it is actually used |
How? |
I don't know if that's possible, I'll have to take a closer look at the code. It's just a thought for now. |
When profiling my program, I find that importing cheap_repr is very expensive. Here's one profiling result using py-spy:
https://laike9m.github.io/images/af9b0d4.svg
Importing cheap_repr took ~8% of the total time. In
__init__.py
, it seems that it should be possible to make@try_register_repr
calls lazy. Especially for registering Pandas handlers, they took most of the time. This becomes worse when users have Pandas installed but didn't really callcheap_repr
on Pandas objects.The text was updated successfully, but these errors were encountered: