term¶
Erlang terms as Python values, and the External Term Format codec.
The classes for the Erlang types that Python has no equivalent of are
exported here; the codec is term.codec.
- class term.Atom¶
-
An Erlang atom: a
strthat encodes back to an atom.It is equal to, and hashes like, the string of the same text, so as a dict key the two are one key:
{Atom('foo'): 1, 'foo': 2}is{'foo': 2}.- static from_string_or_atom(s)¶
Create an Atom from a string or return unchanged if it was an atom.
- class term.BitString(val, last_byte_bits)¶
Bases:
BaseTermA bitstring: bytes whose last byte holds only
last_byte_bits(1..8) significant bits, the high ones. Encodes back to an Erlang bitstring. Decoded with the option"bitstring": "BitString".
- class term.Export(module, function, arity)¶
Bases:
BaseTermAn external fun,
fun Module:Function/Arity(EXPORT_EXT). Not callable from Python, but it can be sent back to Erlang unchanged.
- class term.Fun(mod, arity, pid, index, uniq, old_index, old_uniq, free)¶
Bases:
BaseTermRepresents a pointer to a function in Erlang, with some variable values captured. Not callable from Python.
- class term.ImproperList(elements, tail=<object object>)¶
-
A simple data holder used to pass improper lists back to Erlang. An Erlang improper list looks like [1, 2, 3 | 4] where 4 takes tail slot of last list cell instead of NIL. This is a rare data type and very likely you will not ever need it.
- class term.Pid(node_name, id, serial, creation)¶
Bases:
BasePidRepresents Erlang-style process identifier with 3 components. Node component is always 0 for local node, otherwise it can take arbitrary integer values.
A pid is created by Erlang automatically. Pyrlang Process also generates one when it is born to register itself in the process registry. Pid uniquely identifies a running process in the cluster.
- node_name_¶
NOTE: native encoder assumes this is a string.
- is_local_to(node)¶
Compares self.node_name to other node.node_name :param node: Check whether pid is local to the node. :type node: pyrlang.node.Node
- equals(other)¶
True if
otheris the same pid: node, id, serial and creation.
- class term.Port(node_name, id, creation)¶
Bases:
BaseTermAn Erlang port identifier from another node. Python cannot use it, but it can store it and send it back unchanged: since OTP 26 every node must accept ports with 64-bit ids (
DFLAG_V4_NC).
- class term.Record(module, name, exported, fields)¶
Bases:
BaseTermA native record (EEP-79, OTP 29,
RECORD_EXT):#Module:Name{...}. Native records are experimental in OTP 29 and 30.
- class term.Reference(node_name, creation, refid)¶
Bases:
BaseRefRepresents a reference value from Erlang, typically it has 12 bytes of unique data, but it might change.
- static create(node_name, creation)¶
A new reference of node
node_name, unequal to every other reference this process creates.Its 3 ID words hold a per-process counter (the low 18 bits in the first word, the next 32 in the second) and 32 random bits (third), so a restarted node is unlikely to repeat references it made before.
- Parameters:
- Return type:
- node_name_¶
Node the ref comes from. NOTE: native codec assumes this is a string.
- id_¶
Identification bytes, guaranteed to be unique on the creating node
- equals(other)¶
True if
otheris the same reference: node, creation and id.
Modules
Erlang atoms: |
|
Base classes of the term classes, and the type |
|
Bitstrings whose length is not a whole number of bytes. |
|
The codec: Erlang External Term Format to Python values and back. |
|
Erlang funs: |
|
Improper lists, and helpers for lists of code points. |
|
Erlang process identifiers. |
|
Erlang port identifiers. |
|
Module implements encoder and decoder from ETF (Erlang External Term Format) used by the network distribution layer. |
|
Native records (Erlang/OTP 29). |
|
Erlang references. |
|
Helpers for big-endian integers and for byte dumps. |