---
source: https://iinventedlight.com/library/notes/python-numbers.md
title: "numbers: abstract base classes for the numeric tower"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "PSF License Version 2 (Python Software Foundation); PSF License Version 2 (CPython); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, numbers — Numeric abstract base classes; CPython, numbers documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-23
status: published
approved_by: "Cole Withington, 2026-11-27 14:30 PT: \"Yes, publish all of that now\""
checked_on: 2026-11-23
as_of: 2026-11-23
confidence: medium
untested: "Not reproduced (2026-11-23). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-python: python-numbers"
tags: [python, numbers, abc, numeric-tower]
client: Librarian
sources:
  - id: S1
    title: "numbers — Numeric abstract base classes"
    publisher: Python Software Foundation
    url: https://docs.python.org/3/library/numbers.html
    accessed: 2026-11-23
    license: "PSF License Version 2"
  - id: S2
    title: "numbers documentation (source)"
    publisher: CPython
    url: https://raw.githubusercontent.com/python/cpython/main/Doc/library/numbers.rst
    accessed: 2026-11-23
    license: "PSF License Version 2"
---
# numbers: abstract base classes for the numeric tower
**Answer:** The numbers module defines a hierarchy of numeric abstract base classes. Number is the root of that hierarchy. None of the types defined in this module are intended to be instantiated. To check if x is a number, use isinstance(x, Number).

## The root and the tower

None of the types defined in this module are intended to be instantiated.

If you just want to check if an argument x is a number, use isinstance(x, Number).

Number is the root of the numeric hierarchy.

Complex subclasses describe complex numbers and include the operations that work on the built-in complex type, including real, imag, and conjugate(). All except - and != are abstract.

Real adds the operations that work on real numbers, and it also fills in defaults for complex(), real, imag, and conjugate().

Rational subtypes Real and adds numerator and denominator properties.

## How the source describes the module

A hierarchy of numeric abstract base classes, which progressively define more operations, is what this module provides.

The numeric tower includes Complex, Real, Rational, and Integral.

numerator and denominator should be Integral instances, in lowest terms, with a positive denominator.

## See also

- [python-math](https://iinventedlight.com/library/notes/python-math/)
- [python-decimal](https://iinventedlight.com/library/notes/python-decimal/)
- [python-fractions](https://iinventedlight.com/library/notes/python-fractions/)

## Claims

- id: C1
  claim: None of the types in this module are intended to be instantiated.
  source: S1
  evidence: "None of the types defined in this module are intended to be instantiated"

- id: C2
  claim: Number is the root of the numeric hierarchy.
  source: S1
  evidence: "The root of the numeric hierarchy"

- id: C3
  claim: Use isinstance(x, Number) to check whether x is a number.
  source: S1
  evidence: "use isinstance(x, Number)"

- id: C4
  claim: The module defines a hierarchy of numeric abstract base classes.
  source: S1
  evidence: "hierarchy of numeric abstract base classes"

- id: C5
  claim: Rational adds numerator and denominator properties.
  source: S1
  evidence: "adds numerator and denominator properties"

- id: C6
  claim: The classes progressively define more operations.
  source: S2
  evidence: "progressively define more operations"

## Sources

- [S1] numbers — Numeric abstract base classes. Python Software Foundation. https://docs.python.org/3/library/numbers.html . License: PSF License Version 2. Accessed 2026-11-23.

- [S2] numbers documentation (source). CPython. https://raw.githubusercontent.com/python/cpython/main/Doc/library/numbers.rst . License: PSF License Version 2. Accessed 2026-11-23.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, numbers — Numeric abstract base classes; CPython, numbers documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
