[Python-Dev] Re: PEP 505 (None-aware operators) for Python 3.11

2022-09-19 Thread Guido van Rossum
Personally I think returning None is a fine API design, and IMO the concerns about this pattern are overblown. Note that X|None is no different than the "Maybe X" pattern that functional programmers are so fond of. On Mon, Sep 19, 2022 at 8:02 AM Philipp Burch wrote: > Hi all, > > I've only

[Python-Dev] Re: Annotating pure functions to improve inline caching/optimization

2022-09-19 Thread Philipp Burch
Hi Ken, thank you for the inputs. Just one more comment: I actually find myself often factoring such data out of loops in Python, whereas in C I would just leave that to the optimizer/compiler. The compiler in CPython can't really do that because it's not safe in Python. The user could've

[Python-Dev] Re: PEP 505 (None-aware operators) for Python 3.11

2022-09-19 Thread Philipp Burch
Hi all, I've only here found out that there is a discussion going on about those none-aware operators and my first thought was "great, finally!". FWIW, I'd be happy with the syntax suggestion in the PEP, since '?' looks rather intuitive to me to mean something like "maybe". However, I then

[Python-Dev] Re: Annotating pure functions to improve inline caching/optimization

2022-09-19 Thread Philipp Burch
On 15.09.22 00:05, Jeremiah Gabriel Pascual wrote: I've frequently explored the new adaptive, inline caching code generated by 3.11. "inline caching" does not mean result caching (like what C/C++ might do) here, but rather it should mean the caching of info used for the adaptive instructions.

[Python-Dev] Re: Annotating pure functions to improve inline caching/optimization

2022-09-19 Thread Ken Jin
Hi Phillip, thanks for your interest in CPython. How Python views your code isn't how you view your code. CPython views source code instead as something called "bytecode/wordcode". This bytecode is a lower-level intermediary language that the CPython interpreter executes. You can read more