[pypy-dev] Efficiently piecing together callables with hooks?

Armin Rigo arigo at tunes.org
Mon Aug 15 12:48:09 CEST 2011


Hi Timo,

On Sun, Aug 14, 2011 at 6:48 PM, Timo Paulssen
<timonator at perpetuum-immobile.de> wrote:
>
> So what would you suggest for making this much faster? I read on the IRC, that
> in pypy itself, string concatenation is actually used to create python
> functions, so maybe that would be way to go in this case?

Sorry, I must correct myself.  Using strings to make a function's
source code is used as the "last resort" method; what we usually do is
just make and return local functions, with "global" variables actually
coming from the enclosing scope.  However, at the level of pure
Python, this will not have the effect that you want, because there is
still only one code object.

> Or could pypy offer decorators or other hints to cause pypy
> to unroll and constant-fold different things for me?

Carl Friedrich has played a bit with exposing hints in order to write
interpreters at app-level, but it's not ready for widespread usage.
Right now building new custom code objects is the only solution I can
think of (either by string concatenation, or directly using the ast
module).


A bientôt,

Armin.


More information about the pypy-dev mailing list