Add current opcodes, as implemented by Alexandre

This commit is contained in:
Antoine Pitrou 2013-11-16 19:08:03 +01:00
parent bf9b4e10d1
commit a4b740aacb
1 changed files with 33 additions and 0 deletions

View File

@ -143,6 +143,39 @@ integer, which is wasteful. A specific opcode with a 1-byte length
would make many pickles smaller.
Summary of new opcodes
======================
* ``SHORT_BINUNICODE``: push a utf8-encoded str object with a one-byte
size prefix (therefore less than 256 bytes long).
* ``BINUNICODE8``: push a utf8-encoded str object with a eight-byte
size prefix (for strings longer than 2**32 bytes, which therefore cannot
be serialized using ``BINUNICODE``).
* ``BINBYTES8``: push a bytes object with a eight-byte size prefix
(for bytes objects longer than 2**32 bytes, which therefore cannot be
serialized using ``BINBYTES``).
* ``EMPTY_SET``: push a new empty set object on the stack.
* ``ADDITEMS``: add the topmost stack items to the set (to be used with
``EMPTY_SET``).
* ``EMPTY_FROZENSET``: push a new empty frozenset object on the stack.
* ``FROZENSET``: create a frozenset object from the topmost stack items,
and push it on the stack.
* ``NEWOBJ_EX``: take the three topmost stack items ``cls``, ``args``
and ``kwargs``, and push the result of calling
``cls.__new__(*args, **kwargs)``.
* ``STACK_GLOBAL``: take the two topmost stack items ``module_name`` and
``qualname``, and push the result of looking up the dotted ``qualname``
in the module named ``module_name``.
Alternative ideas
=================