Skip to content
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

Be lazier about variants in methods #6

Open
pganssle opened this issue Dec 8, 2017 · 1 comment
Open

Be lazier about variants in methods #6

pganssle opened this issue Dec 8, 2017 · 1 comment

Comments

@pganssle
Copy link
Member

pganssle commented Dec 8, 2017

The way this works now, the VariantFunction descriptor will create a new VariantMethod at least for every instance of the parent class, possibly on every lookup of either the primary or one of the variants. This is particularly problematic because instantiating a VariantMethod actually eagerly binds every variant at lookup time.

I believe that we can fix this by changing VariantMethod so that rather than eagerly creating bound method variants for every variant of the primary when instantiated, we have a lookup table that lazily creates them in __getattr__.

The big caveat here is that if you just do it the naive way, I'm fairly certain that it will ruin introspection and (probably ruin documentation generation as a consequence), so I think we'll also have to be clever about the introspection.

@pganssle
Copy link
Member Author

I think this can be postponed to the first feature release, since variants works already.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant