Skip to content

Slow first execution of platform.system on windows #95531

Closed as not planned
Closed as not planned
@eendebakpt

Description

@eendebakpt

Bug report

Many python packages make calls to platform.system() or platform.machine() during the import. These functions call the generic platform.uname() . The result of platform.uname() is cached, but the first invocation is slow on windows (>100ms), adding 100ms import time to these packages. The slow part on windows is def _syscmd_ver which starts an external process.

Can we replace _syscmd_ver with a faster version (e.g. calling the windows api directly instead of using a external process)? Or refactor the platform.system() and platform.machine() functions to only retrieve the information required and not the general uname?

Your environment

  • CPython versions tested on: 3.11
  • Operating system and architecture: Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.12only security fixesOS-windowsperformancePerformance or resource usagetype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions