[Python-ideas] Type Hinting - Performance booster ?

Guido van Rossum guido at python.org
Sun Dec 21 17:57:03 CET 2014

What Nick is trying to say is that mypy and other optimizers have been
quite successful without type hints. I believe that Jim Baker is hopeful
that he will be able to do some interesting things for Jython with type
hints though.


On Sat, Dec 20, 2014 at 5:15 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:
> On 21 December 2014 at 09:55, Ludovic Gasc <gmludo at gmail.com> wrote:
>> Hi,
>> I'm only a simple Python developer, not a Type Hinting expert and I don't
>> know if you already discuss about that somewhere, but:
>> With the future official support of Type Hinting in Python, is it means
>> that CPython could use this pieces of information to store variables with
>> more efficient data structures, not only check types ?
>> It could possible to have better performance one day with Type Hinting
>> like you have with Cython (explicit types declaration) or PyPy (guessing
>> types) ?
> The primary goals of the type hinting standardisation effort are improving
> program correctness (through enhanced static analysis) and API
> documentation (through clearer communication of expectations for input and
> output, both in the code, in documentation, and in IDEs). It should also
> allow the development of more advanced techniques for function signature
> based dispatch and other forms of structured pattern matching.
> From a performance perspective though, CPython already has a wide array of
> fast paths for particular builtin types - being able to communicate those
> assumptions more clearly won't automatically make it easier to speed them
> up further (or add more in a maintainable fashion). There's no
> *philosophical* objection to such changes (other than "simplicity is a
> virtue"), there's just a long track record of previous attempts like psyco
> and Unladen Swallow that make it clear that the problem is genuinely *hard*.
> There's also the fact that with both Numba and PyPy now supporting
> selective JIT acceleration of decorated functions within the context of a
> larger CPython application, as well as Cython's existing support for
> precompilation as a C extension, the pattern of profiling to find
> performance critical areas, and finding ways to optimise those, now seems
> well established. (Hence my suggestion the other day that we could likely
> use an introductory how to guide on performance profiling, which could also
> provide suggestions for optimisation tools to explore once the hot spots
> have been found).
> Cheers,
> Nick.
> --
> Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
> _______________________________________________
> 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/

--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20141221/9bcf5663/attachment-0001.html>

More information about the Python-ideas mailing list