Skip to main content

Fast fixed-sized C-like integer types.

Project description

cinc provides fixed-width C-like integer types. The speed of these types are comparable to python ints.


Signed types are named “intN” and unsigned types are named “uintN”, where “N” is the number of bits. Types for 8, 16, 32 and 64 bits are provided.

cinc integers can be constructed from Python ints or cast from another cinc type. If the source integer has more bits than the cinc type then it is truncated:

>>> x = uint32(0xFFFFFFFF)
>>> x
>>> uint16(x)


cinc integers are compatible with python ints. Comparisons and operators cast the integer to their cinc type before performing the comparison or operation.

The result of the operation has the same type as the left operand:

>>> x = uint32(2)
>>> y = int32(2)
>>> x + y
>>> y + x

This applies to operations with python ints too:

>>> x = uint32(2)
>>> x + 2
>>> 2 + x

There are also methods for bit rotate operations and bit insertion and extraction:

>>> x = uint32(0x000000ff)
>>> hex(x.rrotate(8))
>>> y = uint32(0xff000000)
>>> hex(y.insert(0xff, 8, 8))
>>> hex(y.extract(16, 16))

Python Fallback

If no C++ compiler is available during installation, then a Python source module based on ctypes is used instead. The Python version is significantly slower than the compiled C extension.



  • cinc types are now compatible with python ints.
  • A pure Python module was added.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for cinc, version 2.0.post1
Filename, size File type Python version Upload date Hashes
Filename, size cinc-2.0.post1.tar.gz (10.8 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page