[Python-ideas] Performance improvements via static typing
Eric Fahlgren
ericfahlgren at gmail.com
Thu Jul 19 10:02:33 EDT 2018
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180719/4cb777b7/attachment.html>
More information about the Python-ideas
mailing list