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

GH-100117: Make co_lines more efficient #100447

Merged
merged 3 commits into from
Jan 10, 2023

Conversation

brandtbucher
Copy link
Member

@brandtbucher brandtbucher commented Dec 23, 2022

Basically, this just merges all of the entries for a given line range into a single tuple. This can have a dramatic effect on the size of the resulting iterator:

Before:

>>> from dis import dis as example
>>> lines = list(example.__code__.co_lines())
>>> len(lines)
148

After:

>>> from dis import dis as example
>>> lines = list(example.__code__.co_lines())
>>> len(lines)
39

@markshannon
Copy link
Member

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants