x86 cpuid native API
Project description
cpuid-native
Native Python bindings for x86 CPUID instruction
A lightweight C/C++ extension that provides direct, low-level access to x86/x64 processor identification and feature detection through the CPUID instruction.
⚠️ x86/x64 ONLY: This library uses the CPUID instruction which is exclusive to x86/x64 processors. It will NOT work on ARM processors (Apple Silicon M1/M2/M3, Raspberry Pi, AWS Graviton, etc.). Attempting to build or run on ARM will result in compilation errors. This is by design - CPUID is an x86-specific instruction with no ARM equivalent.
Features
- Zero-dependency native extension - Direct CPU instruction access with minimal overhead
- Cross-platform support - Works on Linux, macOS, and Windows
- Wide Python compatibility - Supports Python 3.7 through 3.13
- Low-level control - Direct access to CPUID leaves and subleaves
- Extended instructions - Support for XGETBV and RDTSCP
Installation
pip install cpuid-native
Quick Start
import cpuid_native
# Get basic CPUID information (leaf 0)
success, eax, ebx, ecx, edx = cpuid_native.get_cpuid(0)
print(f"Max supported leaf: {eax}")
# Get CPU features (leaf 1)
success, eax, ebx, ecx, edx = cpuid_native.get_cpuid(1)
print(f"Family/Model/Stepping: {eax:08x}")
# Use count variant for extended leaves
success, eax, ebx, ecx, edx = cpuid_native.get_cpuid_count(7, 0)
print(f"Extended features: {ebx:08x}")
# Check XSAVE extended state
xcr0 = cpuid_native.xgetbv(0)
print(f"XCR0 register: {xcr0:016x}")
# Read timestamp counter
tsc, aux = cpuid_native.rdtscp()
print(f"TSC: {tsc}, AUX: {aux}")
API Reference
get_cpuid(leaf)
Execute CPUID instruction with the specified leaf.
Parameters:
leaf(int): CPUID leaf number (EAX input)
Returns:
- Tuple of
(success, eax, ebx, ecx, edx)where success is 1 if the leaf is supported
get_cpuid_count(leaf, subleaf)
Execute CPUID instruction with leaf and subleaf.
Parameters:
leaf(int): CPUID leaf number (EAX input)subleaf(int): CPUID subleaf number (ECX input)
Returns:
- Tuple of
(success, eax, ebx, ecx, edx)
xgetbv(ctr)
Execute XGETBV instruction to read extended control registers.
Parameters:
ctr(int): Extended control register number (typically 0 for XCR0)
Returns:
- 64-bit value from the specified extended control register
rdtscp()
Read time-stamp counter and processor ID.
Returns:
- Tuple of
(tsc, aux)where tsc is the 64-bit timestamp counter and aux is the processor ID
Use Cases
- CPU feature detection - Check for SSE, AVX, BMI instruction support
- Performance optimization - Select optimal code paths based on CPU capabilities
- System diagnostics - Low-level processor information gathering
- Virtualization detection - Identify hypervisor presence
- Benchmarking - Precise timing with RDTSCP
For High-Level API
For a more Pythonic interface with automatic CPU identification and feature detection, see cpuid which builds on top of this library.
Building from Source
git clone https://github.com/fpelliccioni/cpuid-py-native.git
cd cpuid-py-native
pip install -e .
License
MIT License - see LICENSE file for details.
Credits
Created and maintained by Fernando Pelliccioni
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cpuid_native-0.1.1.tar.gz.
File metadata
- Download URL: cpuid_native-0.1.1.tar.gz
- Upload date:
- Size: 9.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7f032c455083f6161056f8ff51225e79ef14154cdae577b911e37c1281d93026
|
|
| MD5 |
fe074e4ca8aff728304530e3f2911bd2
|
|
| BLAKE2b-256 |
52aef936461aa557995beef5cea466725b23045cbc0073bfc365ecb5acb3d911
|
File details
Details for the file cpuid_native-0.1.1-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: cpuid_native-0.1.1-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 23.6 kB
- Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b004a7f56ec74fc56f6bd2302f53ac9b52892cde479a511cd92a640921dd6fac
|
|
| MD5 |
b5fb7111334cb70cc48bf12ab3e43daf
|
|
| BLAKE2b-256 |
1e87aed1ecc8dcabd918d674722e153d2bbae067750542b34cdf79c8bca41e3f
|
File details
Details for the file cpuid_native-0.1.1-cp313-cp313-macosx_10_13_x86_64.whl.
File metadata
- Download URL: cpuid_native-0.1.1-cp313-cp313-macosx_10_13_x86_64.whl
- Upload date:
- Size: 6.1 kB
- Tags: CPython 3.13, macOS 10.13+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
faf0906bbebcdb787bf504b3a85db25fe50cee629f4a2a563b4ed0822abdaa54
|
|
| MD5 |
7f6fd4ba251424c29872a339c6e3ff4e
|
|
| BLAKE2b-256 |
22948090ed6bdf80969decf32ebbca141645bde0315d7fa73b45654b0c16f59f
|
File details
Details for the file cpuid_native-0.1.1-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: cpuid_native-0.1.1-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 23.7 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1dc2a7d701d3c6d1abaa50865421f66aa2260edd0e3f088997137f9c66059d9e
|
|
| MD5 |
669aa3ad386144ee62b4a98fd0aa8d9a
|
|
| BLAKE2b-256 |
14e9323507a8ee4f5a7edbb5c0b87aeb838677b92072c4bd3c7150ed067dfee8
|
File details
Details for the file cpuid_native-0.1.1-cp312-cp312-macosx_10_13_x86_64.whl.
File metadata
- Download URL: cpuid_native-0.1.1-cp312-cp312-macosx_10_13_x86_64.whl
- Upload date:
- Size: 6.1 kB
- Tags: CPython 3.12, macOS 10.13+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0232ed92e0e677e32b7e32b0f86bbf04bf6b6b4870d6f693cd3b7c9553e7a01a
|
|
| MD5 |
2b89520bc19a34cd0e74841a47345cdc
|
|
| BLAKE2b-256 |
7b386e531f873935b5425dd39641d02270712a0536b2492ba716f0f86ad4dfbd
|
File details
Details for the file cpuid_native-0.1.1-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: cpuid_native-0.1.1-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 23.2 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
851926bf45f79ef1d7baf92241991869a51fffdb41d91e134ee0a6775a97a239
|
|
| MD5 |
ee279d431465448978cfa0e86f25eb7d
|
|
| BLAKE2b-256 |
f30ed07ced6d6e26e929e845ded7ddd9cf8d56cb82cb3ad8f6eff9dcd0322766
|
File details
Details for the file cpuid_native-0.1.1-cp311-cp311-macosx_10_9_x86_64.whl.
File metadata
- Download URL: cpuid_native-0.1.1-cp311-cp311-macosx_10_9_x86_64.whl
- Upload date:
- Size: 6.1 kB
- Tags: CPython 3.11, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3af762850e0205be70d00a83a839406151f209f06b8a44485a6ff8ba7f9ae60e
|
|
| MD5 |
8d0e81db51b2a2e9059d2fdc282e178a
|
|
| BLAKE2b-256 |
8719622a79dfbcdec073a51276ed640b863114df495405140d4726aabb027490
|
File details
Details for the file cpuid_native-0.1.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: cpuid_native-0.1.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 23.2 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
48c8590e97bcb02841eb51a2c6c921e79c38661f93e0da4b8a732144b6bf8b70
|
|
| MD5 |
13bfb82d92c47f347073a3e88d9c432d
|
|
| BLAKE2b-256 |
96dc239b94f34488a5dd046f602d6bbab33a9abef6fbe3fb8d9f0376d99a4e45
|
File details
Details for the file cpuid_native-0.1.1-cp310-cp310-macosx_10_9_x86_64.whl.
File metadata
- Download URL: cpuid_native-0.1.1-cp310-cp310-macosx_10_9_x86_64.whl
- Upload date:
- Size: 6.1 kB
- Tags: CPython 3.10, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
39c0006077e68dcd758f7e124dc835c39c2455c6a3a3aef80ef3ecb421d28f12
|
|
| MD5 |
4817cca287caac27ceeb23e6c17a4d45
|
|
| BLAKE2b-256 |
2f184bd2e1b56d2e0bb9a16125cbee58613475369059f4b3b002afcda4b501b9
|
File details
Details for the file cpuid_native-0.1.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: cpuid_native-0.1.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 23.0 kB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bed57d85e7c8579c2a5adcfb62869e5f0bd556c8c887190e546be5998a6567b1
|
|
| MD5 |
7caeff7e7513e9431efd004d057e004f
|
|
| BLAKE2b-256 |
b63124566d5f1f0aed4c395ef34ada428cd803919d55cb26630441a89039ff51
|
File details
Details for the file cpuid_native-0.1.1-cp39-cp39-macosx_10_9_x86_64.whl.
File metadata
- Download URL: cpuid_native-0.1.1-cp39-cp39-macosx_10_9_x86_64.whl
- Upload date:
- Size: 6.1 kB
- Tags: CPython 3.9, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c3af9c50da4dc1957394a26f2db19696d4af005c9e864474b3dc3676e18e231
|
|
| MD5 |
fffccab994f80ddfe1ece87faf661f89
|
|
| BLAKE2b-256 |
c4fb9d7a2e32d8452c4ff86a73e12bb17ed914629b5189b1e401e9a971367ee4
|