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

optimize pyparsing import time by deferring regex compile #363

Merged
merged 1 commit into from Feb 6, 2022
Merged

optimize pyparsing import time by deferring regex compile #363

merged 1 commit into from Feb 6, 2022

Conversation

asottile
Copy link
Contributor

@asottile asottile commented Feb 5, 2022

resolves #362

using the same script in that PR:

$ python3 -m prof --best-of 10
0.066

@ptmcg ptmcg merged commit dd5c650 into pyparsing:master Feb 6, 2022
@ptmcg
Copy link
Member

ptmcg commented Feb 6, 2022

Looks great, thanks!


@cached_property
def re(self):
if self._re:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be possible to always assign to re and thus remove the extra attribute for a given pattern

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, see __init__

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asottile my understanding is that a cached property can be assigned a value using the same attribute name, as its using the dict as cache

that way the assigment should suffice

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, but self._re is used separately

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

Successfully merging this pull request may close these issues.

3x import-time performance regression between 2.x and 3.x
3 participants