Skip to main content

cpuid-native

PyPI version License: MIT Python Support

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

Metadata

Release files for cpuid-native 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cpuid-native 0.1.1
File Size Uploaded
cpuid_native-0.1.1.tar.gz 9.8 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for cpuid-native 0.1.1
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 CPython 3.13 CPython 3.13 Linux glibc 2.17+ x86-64, Linux glibc 2.5+ x86-64 Details
cpuid_native-0.1.1-cp313-cp313-macosx_10_13_x86_64.whl CPython 3.13 CPython 3.13 macOS 10.13+ x86-64 Details
cpuid_native-0.1.1-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64, Linux glibc 2.5+ x86-64 Details
cpuid_native-0.1.1-cp312-cp312-macosx_10_13_x86_64.whl CPython 3.12 CPython 3.12 macOS 10.13+ x86-64 Details
cpuid_native-0.1.1-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ x86-64, Linux glibc 2.5+ x86-64 Details
cpuid_native-0.1.1-cp311-cp311-macosx_10_9_x86_64.whl CPython 3.11 CPython 3.11 macOS 10.9+ x86-64 Details
cpuid_native-0.1.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.5+ x86-64, Linux glibc 2.17+ x86-64 Details
cpuid_native-0.1.1-cp310-cp310-macosx_10_9_x86_64.whl CPython 3.10 CPython 3.10 macOS 10.9+ x86-64 Details
cpuid_native-0.1.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.5+ x86-64, Linux glibc 2.17+ x86-64 Details
cpuid_native-0.1.1-cp39-cp39-macosx_10_9_x86_64.whl CPython 3.9 CPython 3.9 macOS 10.9+ x86-64 Details

Total release size: 157.0 kB

Release files / cpuid_native-0.1.1.tar.gz

Download URL cpuid_native-0.1.1.tar.gz
Size 9.8 kB
Tags Source
SHA-256 checksum
How to use checksums
7f032c455083f6161056f8ff51225e79ef14154cdae577b911e37c1281d93026
BLAKE2b-256 checksum
How to use checksums
52aef936461aa557995beef5cea466725b23045cbc0073bfc365ecb5acb3d911
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / cpuid_native-0.1.1-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl

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
Size 23.6 kB
Tags CPython 3.13 Linux glibc 2.17+ x86-64 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
b004a7f56ec74fc56f6bd2302f53ac9b52892cde479a511cd92a640921dd6fac
BLAKE2b-256 checksum
How to use checksums
1e87aed1ecc8dcabd918d674722e153d2bbae067750542b34cdf79c8bca41e3f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / cpuid_native-0.1.1-cp313-cp313-macosx_10_13_x86_64.whl

Download URL cpuid_native-0.1.1-cp313-cp313-macosx_10_13_x86_64.whl
Size 6.1 kB
Tags CPython 3.13 macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
faf0906bbebcdb787bf504b3a85db25fe50cee629f4a2a563b4ed0822abdaa54
BLAKE2b-256 checksum
How to use checksums
22948090ed6bdf80969decf32ebbca141645bde0315d7fa73b45654b0c16f59f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / cpuid_native-0.1.1-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl

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
Size 23.7 kB
Tags CPython 3.12 Linux glibc 2.17+ x86-64 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
1dc2a7d701d3c6d1abaa50865421f66aa2260edd0e3f088997137f9c66059d9e
BLAKE2b-256 checksum
How to use checksums
14e9323507a8ee4f5a7edbb5c0b87aeb838677b92072c4bd3c7150ed067dfee8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / cpuid_native-0.1.1-cp312-cp312-macosx_10_13_x86_64.whl

Download URL cpuid_native-0.1.1-cp312-cp312-macosx_10_13_x86_64.whl
Size 6.1 kB
Tags CPython 3.12 macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
0232ed92e0e677e32b7e32b0f86bbf04bf6b6b4870d6f693cd3b7c9553e7a01a
BLAKE2b-256 checksum
How to use checksums
7b386e531f873935b5425dd39641d02270712a0536b2492ba716f0f86ad4dfbd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / cpuid_native-0.1.1-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl

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
Size 23.2 kB
Tags CPython 3.11 Linux glibc 2.17+ x86-64 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
851926bf45f79ef1d7baf92241991869a51fffdb41d91e134ee0a6775a97a239
BLAKE2b-256 checksum
How to use checksums
f30ed07ced6d6e26e929e845ded7ddd9cf8d56cb82cb3ad8f6eff9dcd0322766
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / cpuid_native-0.1.1-cp311-cp311-macosx_10_9_x86_64.whl

Download URL cpuid_native-0.1.1-cp311-cp311-macosx_10_9_x86_64.whl
Size 6.1 kB
Tags CPython 3.11 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
3af762850e0205be70d00a83a839406151f209f06b8a44485a6ff8ba7f9ae60e
BLAKE2b-256 checksum
How to use checksums
8719622a79dfbcdec073a51276ed640b863114df495405140d4726aabb027490
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / cpuid_native-0.1.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl

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
Size 23.2 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
48c8590e97bcb02841eb51a2c6c921e79c38661f93e0da4b8a732144b6bf8b70
BLAKE2b-256 checksum
How to use checksums
96dc239b94f34488a5dd046f602d6bbab33a9abef6fbe3fb8d9f0376d99a4e45
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / cpuid_native-0.1.1-cp310-cp310-macosx_10_9_x86_64.whl

Download URL cpuid_native-0.1.1-cp310-cp310-macosx_10_9_x86_64.whl
Size 6.1 kB
Tags CPython 3.10 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
39c0006077e68dcd758f7e124dc835c39c2455c6a3a3aef80ef3ecb421d28f12
BLAKE2b-256 checksum
How to use checksums
2f184bd2e1b56d2e0bb9a16125cbee58613475369059f4b3b002afcda4b501b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / cpuid_native-0.1.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl

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
Size 23.0 kB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
bed57d85e7c8579c2a5adcfb62869e5f0bd556c8c887190e546be5998a6567b1
BLAKE2b-256 checksum
How to use checksums
b63124566d5f1f0aed4c395ef34ada428cd803919d55cb26630441a89039ff51
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / cpuid_native-0.1.1-cp39-cp39-macosx_10_9_x86_64.whl

Download URL cpuid_native-0.1.1-cp39-cp39-macosx_10_9_x86_64.whl
Size 6.1 kB
Tags CPython 3.9 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
5c3af9c50da4dc1957394a26f2db19696d4af005c9e864474b3dc3676e18e231
BLAKE2b-256 checksum
How to use checksums
c4fb9d7a2e32d8452c4ff86a73e12bb17ed914629b5189b1e401e9a971367ee4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release history Release notifications | RSS feed

This release

0.1.1 This release

11 release files

0.1.0

15 release files

0.0.9

15 release files

0.0.8

11 release files

0.0.7

8 release files

0.0.6

16 release files

0.0.5

11 release files

0.0.4

14 release files

0.0.3

17 release files

0.0.2

10 release files

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page