Skip to content

"import past" is too damn slow #117

Closed
@giampaolo

Description

@giampaolo
$ cat foo.py 
import time
t = time.time()
import past
print time.time() - t
$ python foo.py 
1.248811864853

Note that because of this, also simple and apparently innocuous import statements such as from past.utils import PY3 are very slow.
I tried to debug this a little and it seems this is slow because "import past" causes translations/__init__.py to be imported and in there different lib2to3 fixers are automatically executed.
IMHO just importing any module from the "past" namespace should not take this long (and more definitively not if I'm just importing something as common as "PY3", or "unicode"). I would expect that if any lib2to3 operation has to take place it should occur only if I'm explicitly invoking something like install_aliases().

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions