Skip to main content

Fast arbitrary precision correctly-rounded decimal floating point arithmetic.

Project description


The cdecimal package is a fast drop-in replacement for the decimal module in Python’s standard library. Both modules provide complete implementations of Mike Cowlishaw/IBM’s General Decimal Arithmetic Specification.


Both cdecimal and the underlying library - libmpdec - are extremely well tested. libmpdec is one of the few open source projects with 100% code coverage. cdecimal is rigorously tested against

Short benchmarks

Typical performance gains are between 30x for I/O heavy benchmarks and 80x for numerical programs. In a database benchmark, cdecimal exhibits a speedup of 12x over

  decimal cdecimal speedup
pi 42.75s 0.58s 74x
telco 172.19s 5.68s 30x
psycopg 3.57s 0.29s 12x


Since cdecimal is compatible with, the official documentation is valid. For the few remaining differences, refer to the second link.

Linux Notes

The build process requires a working C compiler and a full Python install with development headers. Linux distributions often ship the Python header files as a separate package, called python-dev or python-devel.

Install headers on Debian/Ubuntu:

  • sudo apt-get install python-dev

Windows Notes

Project details

Release history Release notifications | RSS feed

This version


Download files

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

Source Distribution

gryphon-cdecimal-2.3.tar.gz (383.1 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page