Martin McBride, 2017-04-12
Tags python
Categories python

Python supports integers, floats and complex numbers.


Python uses bignum integers. This means that integers aren't limited to values that fit in 32 bits, or even 64 bits. Integers can be more or less as big as you like, only really limited by how much memory your computer has. For all practical purposes they are unlimited in size.

To see this in action, try this:


The result will be a very large number - a one followed by a thousand zeros! That is quite a massive number - far, far larger than, for example, the number of atoms in the known universe.

Bignums are the default (in fact the only) type of integer Python supports, since Python 3.

Are they efficient? Well, yes they are pretty fast on a modern computer. If you are using Python rather than a compiled languages such as C++, then it will never be quite as fast for highly processor intensive code. But in that context, big integers are not really a significant source of inefficiency.

The benefits


Complex numbers


Numbers are immutable objects

Copyright (c) Axlesoft Ltd 2020