Version 0.6

  • Add stack depth computation based on control flow graph analysis

Version 0.5

  • Add the new bytecode format of Python 3.6.
  • Remove the BaseInstr class which became useless. It was replaced with the Instr class.
  • Documentation: Add a comparison with byteplay and codetransformer.
  • Remove the BaseIntr class: Instr becomes the new base class.
  • Fix PEP 8 issues and check PEP 8 on Travis CI.

2016-04-12: Version 0.4

Peephole optimizer:

  • Reenable optimization on JUMP_IF_TRUE_OR_POP jumping to POP_JUMP_IF_FALSE <target>.

2016-03-02: Version 0.3

New features:

API changes:

  • Rename Block class to BasicBlock
  • Rename BytecodeBlocks class to ControlFlowGraph
  • Rename BaseInstr.op to BaseInstr.opcode
  • Rename BaseBytecode.kw_only_argcount attribute to BaseBytecode.kwonlyargcount, name closer to the Python code object attribute (co_kwonlyargcount)
  • Instr constructor and its set() method now validates the argument type
  • Add Compare enum, used for COMPARE_OP argument of Instr
  • Remove lineno parameter from the BaseInstr.set() method
  • Add CellVar and FreeVar classes: instructions having a cell or free variable now require a CellVar or FreeVar instance rather than a simple string (str). This change is required to handle correctly code with duplicated varible names in cell and free variables.
  • ControlFlowGraph: remove undocumented to_concrete_bytecode() and to_code() methods


Peephole optimizer:

  • Better code for LOAD_CONST x n + BUILD_LIST + UNPACK_SEQUENCE: rewrite LOAD_CONST in the reverse order instead of using ROT_TWO and ROT_THREE. This optimization supports more than 3 items.
  • Remove JUMP_ABSOLUTE pointing to the following code. It can occur after dead code was removed.
  • Remove NOP instructions
  • Bugfix: catch IndexError when trying to get the next instruction.

2016-02-29: Version 0.2

  • Again, the API is deeply reworked.
  • The project has now a documentation: bytecode documentation
  • Fix bug #1: support jumps larger than 2^16.
  • Add a new bytecode.peephole_opt module: a peephole optimizer, code based on peephole optimizer of CPython 3.6 which is implemented in C
  • Add dump_bytecode() function to ease debug.
  • Instr:
  • ConcreteInstr is now mutable
  • Redesign the BytecodeBlocks class:
    • Block have no more label attribute: jump targets are now directly blocks
    • Rename BytecodeBlocks.add_label() method to BytecodeBlocks.split_block()
    • Labels are not more allowed in blocks
    • BytecodeBlocks.from_bytecode() now splits blocks after final instructions (Instr.is_final()) and after conditional jumps (Instr.is_cond_jump()). It helps the peephole optimizer to respect the control flow and to remove dead code.
  • Rework API to convert bytecode classes:
    • BytecodeBlocks: Remove to_concrete_bytecode() and to_code() methods. Now you first have to convert blocks to bytecode using to_bytecode().
    • Remove Bytecode.to_bytecode_blocks() method, replaced with BytecodeBlocks.from_bytecode()
    • Remove ConcreteBytecode.to_concrete_bytecode() and Bytecode.to_bytecode() methods which did nothing (return self)
  • Fix ConcreteBytecode for code with no constant (empty list of constants)
  • Fix argnames in ConcreteBytecode.to_bytecode(): use CO_VARARGS and CO_VARKEYWORDS flags to count the number of arguments
  • Fix const_key() to compare correctly constants equal but of different types and special cases like -0.0 and +0.0

2016-02-26: Version 0.1

  • Rewrite completely the API!

2016-02-23: Release 0.0

  • First public release