Native Python types


Turns ASN.1 object into a Python built-in type object(s).

Takes any ASN.1 object (e.g. PyAsn1Item derivative) walks all its components recursively and produces a Python built-in type or a tree of those.

One exception is that instead of dict, the OrderedDict can be produced (whenever available) to preserve ordering of the components in ASN.1 SEQUENCE.

Parameters:pyasn1 object to encode (or a tree of them)
Returns:object – Python built-in type instance (or a tree of them)
Raises:pyasn1.error.PyAsn1Error – On encoding errors
pyasn1.codec.native.decoder.decode(pyObject, asn1Spec)

Turns Python objects of built-in types into ASN.1 objects.

Takes Python objects of built-in types and turns them into a tree of ASN.1 objects (e.g. PyAsn1Item derivative) which may be a scalar or an arbitrary nested structure.

  • pyObject (object) – A scalar or nested Python objects
  • asn1Spec (any pyasn1 type object e.g. PyAsn1Item derivative) – A pyasn1 type object to act as a template guiding the decoder. It is required for successful interpretation of Python objects mapping into their ASN.1 representations.

PyAsn1Item derivative – A scalar or constructed pyasn1 object


pyasn1.error.PyAsn1Error – On decoding errors