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

Paul Moore p.f.moore at gmail.com
Wed Oct 21 19:31:35 CEST 2015


On 21 October 2015 at 18:12, Brett Cannon <brett at python.org> wrote:
> 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.

Would it be worth focusing on mechanisms like this, which would be of
general use to various projects, and treating Victor's specific
optimisation use case as simply that, a motivating example? At least
in the first instance - as Victor pointed out, previous attempts to
introduce optimisations have always failed because it's not possible
to switch off Python's dynamic nature. So maybe if we had tools which
allowed code to more easily *detect* when Python's dynamic features
have been used (or rather, when they have *not* been used) we'd be in
a better position to develop optimisation strategies that know when
they are appropriate?

(Another example - Victor mentioned that CPython uses
PyFunction_Check, which isn't friendly to function subclasses. A fix
to allow function subclasses to work more seamlessly would be another
useful general mechanism).

Paul


More information about the Python-ideas mailing list