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

a faster Modulefinder #42582

Closed
theller opened this issue Nov 11, 2005 · 3 comments
Closed

a faster Modulefinder #42582

theller opened this issue Nov 11, 2005 · 3 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs)

Comments

@theller
Copy link

theller commented Nov 11, 2005

BPO 1353872
Nosy @theller
Files
  • modulefinder.patch: Speedup patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2006-10-17.19:56:30.000>
    created_at = <Date 2005-11-11.11:51:32.000>
    labels = ['interpreter-core']
    title = 'a faster Modulefinder'
    updated_at = <Date 2006-10-17.19:56:30.000>
    user = 'https://github.com/theller'

    bugs.python.org fields:

    activity = <Date 2006-10-17.19:56:30.000>
    actor = 'theller'
    assignee = 'none'
    closed = True
    closed_date = None
    closer = None
    components = ['Interpreter Core']
    creation = <Date 2005-11-11.11:51:32.000>
    creator = 'theller'
    dependencies = []
    files = ['6863']
    hgrepos = []
    issue_num = 1353872
    keywords = ['patch']
    message_count = 3.0
    messages = ['49008', '49009', '49010']
    nosy_count = 1.0
    nosy_names = ['theller']
    pr_nums = []
    priority = 'normal'
    resolution = 'out of date'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue1353872'
    versions = ['Python 2.5']

    @theller
    Copy link
    Author

    theller commented Nov 11, 2005

    py2exe uses Python's modulefinder to find the modules
    and packages that belong to one or more scripts.

    For not too small projects, the runtime of modulefinder
    is quite long. On my system, the time to find all 533
    modules my project needs is around 48 seconds.

    So, I profiled the Python 2.4 modulefinder, and patched
    it for a speedup of a factor of ~2.5 - the time
    required to find the modules drops to around 19 seconds.

    @theller theller closed this as completed Nov 11, 2005
    @theller theller added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Nov 11, 2005
    @theller theller closed this as completed Nov 11, 2005
    @theller theller added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Nov 11, 2005
    @theller
    Copy link
    Author

    theller commented Nov 11, 2005

    Logged In: YES
    user_id=11105

    Here is a description of the changes in the patch:

    Modulefinder's scan_code method did call ord() on each
    character of the co.co_code string, that took the most time,
    and it built the argument (again with ord() calls) of each
    bytecode that had one, even if it was never used.

    The patch changes the code to

    • work on the characters of the co.co_code string, avoiding
      the calls to ord() altogether
    • create the bytecodes argument only when needed,
    • create the bytecode with struct.pack which is faster.

    I did not stop there, so other changes were that the objects
    that scan_code needs most are passed as default arguments to
    the functions instead of looking them up in the global
    namespace.

    This patch will probably be in the next py2exe release, so
    it will undergo some testing.

    I would appreciate comments on the patch.

    @theller
    Copy link
    Author

    theller commented Oct 17, 2006

    Logged In: YES
    user_id=11105

    This patch is out of date.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    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

    No branches or pull requests

    1 participant