How do I find the class definition for decimal.Decimal?

I'm trying to find the definition of decimal.Decimal but I don't know how.

I tried using inspect but it says OSError: could not find class definition. Can anyone tell me how I would do this? Any help or guidance would be appreciated.


  • A normal CPython installation will have a C implementation in _decimal and a Python implementation in _pydecimal, which could be what is confusing inspect. The Python implementation is used as a fallback if the C implementation is unavailable.

    • Python implementation: find it here in Lib/

    • C implementation: find it here in Modules/_decimal/_decimal.c.