Skip to main content

Python cross-version byte-code assembler

Project description

NOTE: this is in an early beta stage

A Cross-Python bytecode Assembler

Introduction

The Python xasm module has routines for assembly, and has a command to assemble bytecode for several different versions of Python.

Here are some potential uses:

  • Make small patches ot existing Python bytecode when you don’t have source

  • Write more efficient bytecode

  • Write an instruction-level optimizing compiler

  • Experiment and learn about Python Bytecode

  • Foil uncompyle6 in being able to disassemble bytecode

This will support bytecodes from Python version 1.5 to 3.6 or so.

The code requires Python 2.7 or later.

Assembly files

More detail will be filled in, but some principles:

  • Prefered extension for Python assembly is .pyasm

  • assembly is designed to work with the output of pydisasm

  • Assesembly file lables are at the beginning of the line and end in a colon, e.g. ‘END_IF:’

  • instruction offsets in the assembly file are ignored and don’t need to be enteed

  • in those instructions that refer to offsets, if the if the operand is an int, exactly that value will be used for the operand. Otherwise we will look for labels and match up with that

Installation

This uses setup.py, so it follows the standard Python routine:

pip install -r requirements.txt
pip install -r requirements-dev.txt
python setup.py install # may need sudo
# or if you have pyenv:
python setup.py develop

A GNU makefile is also provided so make install (possibly as root or sudo) will do the steps above.

Usage

Run

pyxasm  <Python assembler file>

For usage help pyxasm –help

See Also

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

xasm-0.1.0-py3.5.egg (14.3 kB view hashes)

Uploaded Source

xasm-0.1.0-py3-none-any.whl (9.2 kB view hashes)

Uploaded Python 3

xasm-0.1.0-py2.7.egg (14.0 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page