# Native Python types

pyasn1.codec.native.encoder.encode(asn1Value)

  pyasn1 object to encode (or a tree of them)

  Returns

    `object` – Python built-in type instance (or a tree of them)

  Raises

    PyAsn1Error – On encoding errors

  Examples

  Encode ASN.1 value object into native Python types

      >>> seq = SequenceOf(componentType=Integer())
      >>> seq.extend([1, 2, 3])
      >>> encode(seq)
      [1, 2, 3]

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.

  Parameters

    pyObject (`object`) – A scalar or nested Python objects

  Keyword Arguments

    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.

  Returns

    `PyAsn1Item` derivative – A scalar or constructed pyasn1 object

  Raises

    PyAsn1Error – On decoding errors

  Examples

  Decode native Python object into ASN.1 objects with ASN.1 schema

      >>> seq = SequenceOf(componentType=Integer())
      >>> s, _ = decode([1, 2, 3], asn1Spec=seq)
      >>> str(s)
      SequenceOf:
       1 2 3