[Python-Dev] Re: Helpers for dynamic bytecode generation

2019-10-25 Thread Joe Jevnik via Python-Dev
I think this probably belongs on python-list instead of python-dev because python-dev is for development _of_ python, not _with_ python. To answer your question though, there are a few tools that do this: - https://github.com/vstinner/bytecode - https://github.com/ll/codetransformer I am

Re: [Python-Dev] Register-based VM [Was: Possible performance regression]

2019-02-26 Thread Joe Jevnik via Python-Dev
METH_FASTCALL passing arguments on the stack doesn't necessarily mean it will be slow. In x86 there are calling conventions that read all the arguments from the stack, but the rest of the machine is register based. Python could also look at ABI calling conventions for inspiration, like x86-64 where

Re: [Python-Dev] inconsistency in annotated assigned targets

2018-01-25 Thread Joe Jevnik via Python-Dev
t; This was rejected because in ``for`` it would make it hard to spot the > actual > iterable, and in ``with`` it would confuse the CPython's LL(1) parser. > > > On Thu, Jan 25, 2018 at 3:17 PM, Jelle Zijlstra > wrote: > >> >> >> 2018-01-25 15

[Python-Dev] inconsistency in annotated assigned targets

2018-01-25 Thread Joe Jevnik via Python-Dev
Currently there are many ways to introduce variables in Python; however, only a few allow annotations. I was working on a toy language and chose to base my syntax on Python's when I noticed that I could not annotate a loop iteration variable. For example: for x: int in range(5): ... This led

Re: [Python-Dev] Unexpected bytecode difference

2018-01-19 Thread Joe Jevnik via Python-Dev
As a general rule, you should not expect the bytecode to be the same between different versions of CPython, including minor version changes. For example, the instructions for dictionary literals are different in 3.4, 3.5, and 3.6. On Fri, Jan 19, 2018 at 6:54 PM, Victor Stinner wrote: > Python b

Re: [Python-Dev] Inplace operations for PyLong objects

2017-09-01 Thread Joe Jevnik via Python-Dev
The string concat optimization happens in the interpreter dispatch for INPLACE_ADD On Fri, Sep 1, 2017 at 9:10 PM, Greg Ewing wrote: > Chris Angelico wrote: > >> This particular example is safe, because the arguments get passed >> individually - so 'args' has one reference, plus there's one more

Re: [Python-Dev] Inplace operations for PyLong objects

2017-09-01 Thread Joe Jevnik via Python-Dev
Is it true that checking for refcount == 1 is enough? What if a user wrote: args = (compute_integer(), 5) # give away args to someone int.__iadd__(*args) here `args[0]` still has refcount=1 because only `args` owns this integer. On Fri, Sep 1, 2017 at 4:19 PM, Jelle Zijlstra wrote: > > > 2017-