Skip to content

Slowdown of pytest collection in sqlalchemy in python 3.9+ #9343

@CaselIT

Description

@CaselIT
  • a detailed description of the bug or problem you are having
  • output of pip list from the virtual environment you are using
  • pytest and operating system versions
  • minimal example if possible

We noticed that from python 3.9 pytest takes a significantly more time (~4x) to collect the tests for sqlalchemy.
You can run the following docker to compare. python 3.7 and 3.8 are ok (not fast not slow), python 3.9 and 3.10 are noticeably slower

docker run -ti --name py --rm python:3.7 bash -c 'git clone https://github.com/sqlalchemy/sqlalchemy.git --depth 100; pip install pytest; cd sqlalchemy; time pytest --collect-only'
docker run -ti --name py --rm python:3.8 bash -c 'git clone https://github.com/sqlalchemy/sqlalchemy.git --depth 100; pip install pytest; cd sqlalchemy; time pytest --collect-only'
docker run -ti --name py --rm python:3.9 bash -c 'git clone https://github.com/sqlalchemy/sqlalchemy.git --depth 100; pip install pytest; cd sqlalchemy; time pytest --collect-only'
docker run -ti --name py --rm python:3.10 bash -c 'git clone https://github.com/sqlalchemy/sqlalchemy.git --depth 100; pip install pytest; cd sqlalchemy; time pytest --collect-only'

the times on my pc are as floows:

#py37
real    0m27.949s
user    0m26.717s
sys     0m1.220s
#py38
real    0m27.952s
user    0m26.893s
sys     0m1.050s
# py39
real    1m45.581s
user    1m42.574s
sys     0m2.990s
# py310
real    1m46.255s
user    1m43.648s
sys     0m2.590s

cc @zzzeek

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