MacroPy is an implementation of Macros in the Python Programming Language. MacroPy provides a mechanism for user-defined functions (macros) to perform transformations on the abstract syntax tree(AST) of Python code at module import time. This is an easy way to modify the semantics of a python program
Python like you’ve never seen before
MacroPy allows you to create constructs which are impossible to have in normal python code, such as:
Tracing
with trace:
sum([x + 5 for x in range(3)])
# sum([x + 5 for x in range(3)])
# range(3) -> [0, 1, 2]
# x + 5 -> 5
# x + 5 -> 6
# x + 5 -> 7
# [x + 5 for x in range(3)] -> [5, 6, 7]
# sum([x + 5 for x in range(3)]) -> 18
Quick Lambdas
print map(f[_[0]], ['omg', 'wtf', 'bbq'])
# ['o', 'w', 'b']
print reduce(f[_ + _], ['omg', 'wtf', 'bbq'])
# 'omgwtfbbq
Case Classes
@case
class Point(x, y): pass
p = Point(1, 2)
print str(p) #Point(1, 2)
print p.x #1
print p.y #2
print Point(1, 2) == Point(1, 2) # True
And more! All this runs perfectly on vanilla Python 2.7 or PyPy 2.0. For more details, see the GitHub page. or ask in the Google Group.
Metadata
Release files for MacroPy 1.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| MacroPy-1.0.3.zip | 36.8 kB | Without provenance | Details |
Release files / MacroPy-1.0.3.zip
| Download URL | MacroPy-1.0.3.zip |
|---|---|
| Size | 36.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e667550a9887db625fb1ee1fee8cdadb02bee2d748ade8620d7d082463f0117b
|
|
BLAKE2b-256 checksum How to use checksums |
f27f84ace573b16d10e2d930ecfb90933e77b14fa2dc12064b3b68a5c0ff5579
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for MacroPy 1.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.