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

Copy link
Contributor

@diegorusso diegorusso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm OK with the changes, just a minor comment on win-arm32 (that in my opinion we shouldn't need)

# platform: (arch, bits, linkage)
'win32': ('x86', '32bit', 'WindowsPE'),
'win-amd64': ('AMD64', '64bit', 'WindowsPE'),
'win-arm32': ('ARM', '32bit', 'WindowsPE'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really care about Windows on Arm 32bit? This is specifically Windows RT 8.1 which ended support in 2023.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From https://learn.microsoft.com/en-us/windows/arm/arm32-to-arm64

Windows devices running on an Arm processor (...) no longer support AArch32 (Arm32). This change impacts Universal Windows Platform apps that presently target AArch32 (Arm32). Support for 32-bit Arm versions of applications is removed in a future release of Windows 11.

Copy link
Contributor

@diegorusso diegorusso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually while we are here, we should update the documentation as well (if it is found to be inconsistent)

@malemburg
Copy link
Member

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.

The platform module is meant for inspecting the platform Python runs on, sysconfig normally refers to the platform and settings it was compiled with.

As for return values, "win-arm64" is not an architecture. The "win-" part refers to the OS.

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.

3 participants