Skip to content

gh-145410: Use _sysconfig.get_platform() in the platform module#146148

Open
vstinner wants to merge 4 commits intopython:mainfrom
vstinner:platform_sysconfig
Open

gh-145410: Use _sysconfig.get_platform() in the platform module#146148
vstinner wants to merge 4 commits intopython:mainfrom
vstinner:platform_sysconfig

Conversation

@vstinner
Copy link
Member

@vstinner vstinner commented Mar 18, 2026

@vstinner vstinner changed the title gh-146145: Use _sysconfig.get_platform() in the platform module gh-145410: Use _sysconfig.get_platform() in the platform module Mar 18, 2026
@vstinner
Copy link
Member Author

The change avoids the WMI query (SELECT Architecture FROM Win32_Processor) in platform.machine() for these 4 sysconfig platforms: win32, win-amd64, win-arm32 and win-arm64.

cc @zooba

@vstinner
Copy link
Member Author

See also issues gh-102536 and gh-98962.

@malemburg
Copy link
Member

This looks fine, but can we be sure that the output does not change across supported Windows platforms ?

@vstinner
Copy link
Member Author

According to #98962 (comment) comment, platform.architecture() is always ARM64, whereas sysconfig.get_platform() can be win-arm64, win-amd64 or win32 when Python is built for different architectures and run on ARM64 Windows. So it seems like platform.architecture() is not directly related to sysconfig.get_platform(), they can be different and my change is wrong.

@vstinner
Copy link
Member Author

cc @diegorusso

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants