[Python-ideas] Add specialized bytecode with guards to functions

Brett Cannon brett at python.org
Wed Oct 21 19:12:34 CEST 2015


On Wed, 21 Oct 2015 at 10:00 Guido van Rossum <guido at python.org> wrote:

> On Wed, Oct 21, 2015 at 9:50 AM, Victor Stinner <victor.stinner at gmail.com>
> wrote:
>
>> 2015-10-21 18:20 GMT+02:00 Guido van Rossum <guido at python.org>:
>> >  I haven't tried the prototype yet, but I wonder if this mightn't be a
>> > useful addition to an existing optimizing Python system, e.g. PyPy or
>> (plug
>> > :-) Pyston?
>>
>> I'm not sure that specialized functions with guards would benefit to
>> JIT compilers.
>>
>
> Pyston is not primarily a JIT compiler (at least that's my understanding).
>

There GitHub project seems to suggest otherwise based on them saying they
are leveraging LLVM's JIT: https://github.com/dropbox/pyston#pyston-- .


>
> And my point was the opposite: Pyston (or PyPy, less sure) might benefit
> from your idea.
>

As would Pyjion (which is really early work and being played with in Dino
and my spare time at work): https://github.com/microsoft/pyjion . We would
probably love to see at least the dict watcher get into CPython. I know
this was something that Unladen Swallow really wanted as well for easy
optimizations of built-in functions. Extend dict watchers to a module's or
class' __dict__ and you start to get more inlining opportunities as Victor
is hoping for. But as a starting point, getting some way to cheaply detect
when the built-ins have not been modified from what they are set to by
default would be nice to have.

-Brett


>
>
>> A best match is with Cython, pythran and other projects generating a
>> specialized version of a function (in native code), maybe releasing
>> the GIL. It would be cool to be able to use a specialized version
>> under some conditions. For example, if parameters are all floats, use
>> the specialized version optimized by Cython, other fallback to the
>> (slow) regular bytecode. The challenge is to automate everything and
>> make it easy to use.
>>
>> I don't know if Numba would match with this design.
>>
>
> Admittedly these are also very attractive-looking pairings!
>
> --
> --Guido van Rossum (python.org/~guido)
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20151021/e6194332/attachment.html>


More information about the Python-ideas mailing list