/cpuid

An example project demonstrating how to include assembly code into a Python-compatible shared library which can be imported into the CPython runtime execution.

Primary LanguageAssembly

cpuid

An example project demonstrating how to include assembly code into a Python-compatible shared library which can be imported into the CPython runtime execution.

This project doesn't do much except it can run an x86/64 instruction that is normally unavailable to processes. This project is mostly to see if it could be done, it doesn't have much use other than a template, so far.

Copyright 2022 Luke Campbell

See LICENSE for details.

Dependencies

This project requires an installation of Python 3, and the build-essentials package (gcc, gnu-make)

Building

make

Running

The make process produces a cpuid.so which can be imported by CPython:

import cpuid
cpuid.cpuid()

API

cpuid.cpuid() returns a tuple of 3 values:

  • The CPU vendor string
  • CPU feature information (see EDX, and ECCX columns in the "additional inforamation" table here.)
  • CPU extended feature information (See EBX, ECX, EDX colums in the "extended features" table here.)