Package: macropy3
MacroPyis an implementation ofSyntactic Macrosin thePython Programming Language. MacroPy provides a mechanism for user-defined
functions (macros) to perform transformations on theabstract syntax
tree(AST) of a
Python program atimport time. This is an easy way to enhance the
semantics of a Python program in ways which are otherwise impossible,
for example providing an extremely concise way of declaring classes.Python like you’ve never seen beforeMacroPy allows you to create constructs which are impossible to have
in normal python code, such as:Tracingwithtrace:sum([x+5forxinrange(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)]) -> 18Quick Lambdasprint(list(map(f[_[0]],['omg','wtf','bbq'])))# ['o', 'w', 'b']print(list(reduce(f[_+_],['omg','wtf','bbq'])))# 'omgwtfbbqCase Classes@caseclassPoint(x,y):passp=Point(1,2)printstr(p)#Point(1, 2)printp.x#1printp.y#2printPoint(1,2)==Point(1,2)# Trueand more! See the docs athttp://macropy3.readthedocs.io/en/latest/.RequirementsMacroPy3 is tested to run onCPython 3.4or newer andPyPy3.5. I has no current support forJython. MacroPy3 is also available onPyPI.InstallationJust execute a:$pipinstallmacropy3if you want to use macros that require external libraries in order to
work, you can automatically install those dependencies by installing
one of thepinqorpyxlextras like this:$pipinstallmacropy3[pinq,pyxl]then have a look at the docs athttp://macropy3.readthedocs.io/en/latest/.How to contributeWe’re open to contributions, so send us your
ideas/questions/issues/pull-requests and we’ll do our best to
accommodate you! You can ask questions on theGoogle Groupand on theGitter channelor file bugs on
theeissuespage.CreditsMacroPy was initially created as a final project for theMITclass6.945: Adventures in Advanced Symbolic
Programming,
taught byGerald Jay SussmanandPavel Panchekha. Inspiration was taken from project such
asScala Macros,KarnickelandPyxl.The MIT License (MIT)Copyright (c) 2013-2018,Li Haoyi,Justin
Holmgren,Alberto Bertiand all the other contributorsPermission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the “Software”), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.Changelog1.1.0 (unreleased)1.1.0b2 (2018-05-12)Fix readme.1.1.0b1 (2018-05-12)Fix and re-enable theSaveExporter()class.Fix some issues with pattern matching module requiring non obvious
imports from user’s side.Fix pattern matching macro need to import_matchingsymbolAdd anOptionalMatcherto pattern matching macro to support
exclusive or conditions.Refactor documentation using sphinx.Refactor the macro expansion core code. Now the macro expansion
order is from inside-out. This allows to use macros inside other
macro’s body.Added support for Python 3.4.AddedSELECT * FROM countryemulation inpinqmacro.Update the examples.Update tco and pyxl macros.Prevent the import hooks from raising errors.1.0.4.dev2 (2017-09-08)Add MANIFEST.in;1.0.4.dev1 (2017-09-08)Updated the import machinery and macro detection to be compatible
with Python 3.5+.Removed support for Python 2, supporting it would require a way to
manage differences at the ast level, but i don’t use Python2 anymore.Added support for Python 3.5+ in the form of new call arguments form
and newAsyncFunctionDef.Basic scope analysis now available in the form of the@Scopeddecorator, to be used in conjunction with@Walker.1.0.3Error messages are now raised at run-time rather than at import
time, with other improvements (double stack traces, catchability).@enummacro now has much better error messagesImproved error messages for mis-use of stub functions outside their
related macro (e.g. theu,name,aststubs for theq/hqmacros)Improved error messages for invalid case class signaturesHygienic Quasiquotes now allow lexical capture of module objects1.0.2Removed unit test from PyPI distribution1.0.1Fixed a bug inast_ctx_fixergen_sym()is nowgen_sym(name="sym"), allowing you to override the base nameImplementedmacropy.case_classes.enummacroImplementedmacropy.quick_lambda.lazyandmacropy.quick_lambda.internedmacros