PyCPUID Documentation Release 0.5 Bram de Greve March 13, 2016
Contents 1 Introduction 3 1.1 Installation.............................................. 3 1.2 Source Code............................................. 3 1.3 Documentation............................................ 3 2 Using PyCPUID 5 3 Changes 7 3.1 0.4.................................................. 7 3.2 0.3.................................................. 7 3.3 0.2.................................................. 7 3.4 0.1.................................................. 7 4 To Do 9 5 Credits 11 6 pycpuid 13 6.1 pycpuid Package........................................... 13 7 Indices and tables 15 Python Module Index 17 i
ii
PyCPUID Documentation, Release 0.5 Contents: Contents 1
PyCPUID Documentation, Release 0.5 2 Contents
CHAPTER 1 Introduction PyCPUID reads the information available from the CPUID assembly instruction and makes it available to any Python program. It could be used to decide on some codepath based on whether the target computer supports SSE2. import pycpuid if pycpuid.has_sse2: import foobar_sse2 as foobar else: import foobar It is not the goal of PyCPUID to provide a full report of all CPUID information available. It s merely a way to get raw access to the machine instruction from within Python. Some functions are provided for translation to something human readable, but this is far from complete. Full details on how to interpret the raw data can be found in the application notes of Intel and AMD. Project maintained by Flight Data Services and released under the GNU Lesses General Public License (LGPL- 2.1). 1.1 Installation Package requires pip for installation. pip install PyCPUID If you re doing this on Windows you ll need to make sure you have a C++ compiler installed and properly configured. 1.2 Source Code Source code is available from GitHub: https://github.com/organizations/flightdataservices/pycpuid 1.3 Documentation Documentation is available from the Python Package Index: http://packages.python.org/pycpuid/ 3
PyCPUID Documentation, Release 0.5 4 Chapter 1. Introduction
CHAPTER 2 Using PyCPUID There s not much to it, really. PyCPUID is just a bunch of module constants. Just import the module and access the constants. The HAS_FOOBAR constants are Boolean flags to indicate whether the feature is available. The function features() returns a list of all the available features as strings. There are some other functions like vendor() and brand_string() you can use to identify the CPU. import pycpuid print "has SSE2:", pycpuid.has_sse2 print "all availabe features:", pycpuid.features() print "brand string:", pycpuid.brand_string() 5
PyCPUID Documentation, Release 0.5 6 Chapter 2. Using PyCPUID
CHAPTER 3 Changes 3.1 0.4 Mostly PEP8 compliant. 3.2 0.3 Should now compile on 32-bit and 64-bit platforms. Updated packaging and now uses SetupFixer. Added documentation based on the original text from Bram. 3.3 0.2 The feature abbreviations now resemble the ones in the Intel and AMD documentation. features() is now a function and returns a list of strings, instead of being a comma separated string. Added some functions like vendor() and brand_string() as handy wrappers. PyCPUID is now a combination of a pure python module pycpuid.py and an extension _pycpuid.c. The extension module is only responsible for the actual cpuid call. All the fancy wrapper bits are implemented in Python. Added gcc support. Using cpuid intrinsic on MSVC to support x64. 3.4 0.1 Initial release. 7
PyCPUID Documentation, Release 0.5 8 Chapter 3. Changes
CHAPTER 4 To Do Hopefully, nothing. 9
PyCPUID Documentation, Release 0.5 10 Chapter 4. To Do
CHAPTER 5 Credits PyCPUID was written by Bram de Greve <bram.degreve@bramz.net> and is maintained by Flight Data Services, Ltd <developers@flightdataservices.com>. 11
PyCPUID Documentation, Release 0.5 12 Chapter 5. Credits
CHAPTER 6 pycpuid 6.1 pycpuid Package 6.1.1 pycpuid Package 6.1.2 pycpuid Module pycpuid.pycpuid.brand_id() pycpuid.pycpuid.brand_string() pycpuid.pycpuid.cpuid(infotype) -> (eax, ebx, ecx, edx) pycpuid.pycpuid.family() pycpuid.pycpuid.features() [str, str,...] returns sequence of available features pycpuid.pycpuid.model() pycpuid.pycpuid.processor_type() pycpuid.pycpuid.stepping_id() pycpuid.pycpuid.vendor() 13
PyCPUID Documentation, Release 0.5 14 Chapter 6. pycpuid
CHAPTER 7 Indices and tables genindex modindex search 15
PyCPUID Documentation, Release 0.5 16 Chapter 7. Indices and tables
Python Module Index p pycpuid. init, 13 pycpuid.pycpuid, 13 17
PyCPUID Documentation, Release 0.5 18 Python Module Index
Index B brand_id() (in module pycpuid.pycpuid), 13 brand_string() (in module pycpuid.pycpuid), 13 C cpuid() (in module pycpuid.pycpuid), 13 F family() (in module pycpuid.pycpuid), 13 features() (in module pycpuid.pycpuid), 13 M model() (in module pycpuid.pycpuid), 13 P processor_type() (in module pycpuid.pycpuid), 13 pycpuid. init (module), 13 pycpuid.pycpuid (module), 13 S stepping_id() (in module pycpuid.pycpuid), 13 V vendor() (in module pycpuid.pycpuid), 13 19