Skip to main content

Meta

A Pure Python module containing a framework to manipulate and analyze python ast’s and bytecode.

Example

This shows how to take python source to a code object and back again from within python:

import meta, ast
source = '''
a = 1
b = 2
c = (a ** b)
'''

mod = ast.parse(source, '<nofile>', 'exec')
code = compile(mod, '<nofile>', 'exec')

mod2 = meta.decompile(code)
source2 = meta.dump_python_source(mod2)

assert source == source2

This shows the depyc script. The script compiles itself, and then the compiled script extracts itself:

DEPYC_FILE=`python -c"import meta.scripts.depyc; print meta.scripts.depyc.__file__"`
depyc $DEPYC_FILE --pyc > depycX.pyc
python -m depycX depycX.pyc --python > depycX.py
echo depycX.py

Notes

  • Meta is python3 compliant (mostly)

Bugs

  • The decompliler does not yet support complex list/set/dict - comprehensions

Testing

python -m unittest discover meta

Metadata

Release files for meta 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for meta 0.4.1
File Size Uploaded
meta-0.4.1.tar.gz 45.9 kB Details

Release files / meta-0.4.1.tar.gz

Download URL meta-0.4.1.tar.gz
Size 45.9 kB
Tags Source
SHA-256 checksum
How to use checksums
58d2c012beea9f2aaea82fbf67d0d6b3124e66c79cbc31829beb2005c3372885
BLAKE2b-256 checksum
How to use checksums
c32fe6952e4dd293c42f3ac1249700e5c3e13bda91e1421377ede0940ef1efd3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

1.0.2

1 release file

1.0.0

1 release file

This release

0.4.1 This release

1 release file

0.4.0

1 release file

0.3.0

1 release file

0.2.4

1 release file

0.2.3

1 release file

0.2.2

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page