[Python-ideas] Performance improvements via static typing

Stephan Houben stephanh42 at gmail.com
Thu Jul 19 10:07:58 EDT 2018


You are aware of numba?

https://numba.pydata.org/

Stephan

Op do 19 jul. 2018 16:03 schreef Eric Fahlgren <ericfahlgren at gmail.com>:

> On Thu, Jul 19, 2018 at 6:52 AM Michael Hall <python-ideas at michaelhall.tech>
> wrote:
>
>> While I am aware of projects like Cython and mypy, it seems to make sense
>> for CPython to allow optional enforcement of type hints, with compiler
>> optimizations related to it to be used. While this would not receive the
>> same level of performance benefits as using ctypes directly, there do
>> appear to be various gains available here.
>>
>
> ​Just to make sure I understand:  In other words, they would no longer be
> "hints" but "guarantees".  This would allow an optimizer pass much greater
> latitude in code generation, somehow or other.​
>
> For purposes of illustration (this is not a proposal, just for
> clarification):
>
> @guaranteed_types
> def my_sqrt(x:c_double) -> c_double:
>     ...
>
> would tell the compiler that it's now possible to replace the general
> PyObject marshalling of this function with a pure-C one that only accepts
> doubles and woe be unto those who use it otherwise.
>
> _______________________________________________
> 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/20180719/10bfb227/attachment-0001.html>


More information about the Python-ideas mailing list