classification
Title: Built-in platform module does not offer to check for processor instructions
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.10
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: PedanticHacker, ammar2, christian.heimes, eric.smith
Priority: normal Keywords:

Created on 2020-07-12 16:15 by PedanticHacker, last changed 2020-07-16 19:41 by ammar2. This issue is now closed.

Messages (9)
msg373563 - (view) Author: Boštjan Mejak (PedanticHacker) * Date: 2020-07-12 16:15
The platform module does not offer to check whether a processor supports the POPCNT or BMI/BMI2 processor instructions. Am I missing something or is it actually missing this feature?
msg373565 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2020-07-12 16:43
Python's standard library doesn't aim to solve all problems. Python also supports a lot of platforms and CPU architectures. We'd have to implement this on major platforms like BSD, Linux, and Windows as well as other supported platforms like AIX or VMS multiplied by all support CPUs architectures like X86, X86_64, multiple ARMs, ...

This sounds like a feature that can be implemented in a PyPI package.
msg373566 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2020-07-12 19:02
What would you use this information for, if it were available from Python code?
msg373580 - (view) Author: Boštjan Mejak (PedanticHacker) * Date: 2020-07-13 01:17
This feature is needed for a chess GUI application because the Stockfish chess engine is offered in different builds: a build that supports the POPCNT processor instruction and a build that doesn't, a build that supports the BMI/BMI2 processor instruction set, a 32-bit build and a 64-bit build, also a Windows build and a Linux build.

Then the chess GUI application can check if the processor supports the POPCNT instruction or the BMI/BMI2 processor instruction set and can load an appropriate Stockfish build to analyze a chess game or play against a human chess player by using the appropriate Stockfish build for the machine the chess GUI application is running on.
msg373639 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2020-07-14 15:13
I think your best bet will be to write a small C extension to find out what's supported by the processor.
msg373643 - (view) Author: Boštjan Mejak (PedanticHacker) * Date: 2020-07-14 15:36
Unfortunately, I don't know C, only Python.
msg373735 - (view) Author: Ammar Askar (ammar2) * (Python triager) Date: 2020-07-16 01:24
Your best bet then is probably using a library built for this purpose like https://github.com/workhorsy/py-cpuinfo

Like Christian said, exposing this information in the standard library would be a fairly large maintenance burden for a feature that can't really be actioned upon from pure Python code.
msg373762 - (view) Author: Boštjan Mejak (PedanticHacker) * Date: 2020-07-16 19:26
Thanks for letting me know about py-cpuinfo. It is a very good tool. It solves my problem. This Python issue can now be closed as "Won't fix".
msg373763 - (view) Author: Ammar Askar (ammar2) * (Python triager) Date: 2020-07-16 19:41
Thanks for your understanding Boštjan, closing this as requested.
History
Date User Action Args
2020-07-16 19:41:38ammar2setstatus: open -> closed
resolution: rejected
messages: + msg373763

stage: resolved
2020-07-16 19:26:17PedanticHackersetmessages: + msg373762
2020-07-16 01:24:31ammar2setnosy: + ammar2
messages: + msg373735
2020-07-14 15:36:22PedanticHackersetmessages: + msg373643
2020-07-14 15:13:45eric.smithsetmessages: + msg373639
2020-07-13 01:17:23PedanticHackersetmessages: + msg373580
2020-07-12 19:02:01eric.smithsetnosy: + eric.smith
messages: + msg373566
2020-07-12 16:43:02christian.heimessetnosy: + christian.heimes

messages: + msg373565
versions: - Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9
2020-07-12 16:15:24PedanticHackercreate