[Python-ideas] Statically checking purity of functions
Victor Stinner
victor.stinner at gmail.com
Tue Jun 21 17:14:08 EDT 2016
Le 9 juin 2016 9:48 PM, "Robert Collins" <robertc at robertcollins.net> a
écrit :
> The problem, as Cory demonstrates, is that purity is transitive: you
> have to know that all the runtime interactions are also pure, or your
> function stops being pure.
FAT Python implements optimizations on pure functions like inlining but
disable optimizations as soon as an assumption becomes false. There is no
magic, it runs checks at runtime using guards.
JIT compilers do the same.
Some projects like numba or pythran don't implement guards, but it's a
deliberate choice to maximize performance. It's acceptable because they use
opt-in optimizations.
Victor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160621/dc06d07b/attachment.html>
More information about the Python-ideas
mailing list