Getting in to metaprogramming

Kay Schluehr kay.schluehr at gmx.net
Wed Nov 26 13:15:15 EST 2008


On 27 Nov., 05:41, "Hendrik van Rooyen" <m... at microcorp.co.za> wrote:

> Given that, can anybody think of an example that you could not do with
> a class?  (excepting the "stored procedure" aspect)

I just noticed that corepy 1.0 [1] has been released. Corepy is an
embedded DSL for synthesizing machine code from chaining Python
commands. This means it provides objects and exploits control
structures used to create machine code that can finally be executed
interactively.

Let's say you have an ordinary Python function that computes a CRC 32.
Now you could attempt to translate the function into other Python code
that expresses a corepy routine. You could create a decorator that
works as follows

1) reads the source of the decorated function
2) transforms the source into corepy source and compiles it or
3) if 2) fails it just returns the passed code object.

Kay

[1] http://www.corepy.org/



More information about the Python-list mailing list