IntegerType

class asdf.IntegerType(value, storage_type='internal')[source]

Bases: object

Enables the storage of arbitrarily large integer values

The ASDF Standard mandates that integer literals in the tree can be no larger than 64 bits. Use of this class enables the storage of arbitrarily large integer values.

When reading files that contain arbitrarily large integers, the values that are restored in the tree will be raw Python int instances.

Parameters:
value: `numbers.Integral`

A Python integral value (e.g. int or numpy.integer)

storage_type: `str`, optional

Optionally overrides the storage type of the array used to represent the integer value. Valid values are “internal” (the default) and “inline”

Examples

>>> import asdf
>>> import random
>>> # Create a large integer value
>>> largeval = random.getrandbits(100)
>>> # Store the large integer value to the tree using asdf.IntegerType
>>> tree = dict(largeval=asdf.IntegerType(largeval))
>>> with asdf.AsdfFile(tree) as af:
...     af.write_to('largeval.asdf')
>>> with asdf.open('largeval.asdf') as aa:
...     assert aa['largeval'] == largeval