I personally find that keyword only arguments make for nicer APIS. It also
makes subclassing easier because you are free to add new positional
arguments later. Especially for boolean arguments, I think keyword only is
a great API choice.
On Tue, Apr 14, 2015 at 2:06 PM, Steven D'Aprano
wrote:
>
The iterator is not revaluated, instead, it is constructing a single
iterator, in this case a list_iterator. The list_iterator looks at the
underyling list to know how to iterate so when you mutate the underlying
list, the list_iterator sees that. This does not mee the expression used to
generate t
Sorry about introducing this. Where can I subscribe to these automated
emails. Also, how do I go about running this locally? On default I tried
running
`./python -m test -l test_capi` did not print anything about leaks. I think
that
using `object.__new__` as a decorator here is the same as subclass
The number and meaning of the arguments are documented in the dis module:
https://docs.python.org/3.6/library/dis.html
On Sat, Dec 26, 2015 at 5:20 PM, Erik wrote:
> Hi.
>
> Looking at ceval.c and peephole.c, there is - of course - lots of specific
> hard-coded knowledge of the bytecode (e.g., n
All arguments are 2 bytes, if there needs to be more, EXTENDED_ARG is used
On Sat, Dec 26, 2015 at 5:51 PM, Erik wrote:
> Hi Joe,
>
> On 26/12/15 22:36, Joe Jevnik wrote:
>
>> The number and meaning of the arguments are documented in the dis
>> module: https://doc
You want to put the `xor` method in the `nb_xor` field of the
`PyNumberMethods` structure that lives in the `tp_as_number` field of the
bytes type object. Two things I noticed in a quick pass: you might want to
add some type checking around the case where `a` or `b` is not a
`PyByteArray` object. A
> Is it possible to add a key, triggering a resize of the dict, then
remove one, and continue iterating through the old (deallocated)
memory?
You can add and remove keys between calling next which would resize the
dictionary; however, it will not iterate through uninitialized memory. The
dictiter
List, set, and dict comprehensions compile like:
# input
result = [expression for lhs in iterator_expression]
# output
def comprehension(iterator):
out = []
for lhs in iterator:
out.append(expression)
return out
result = comprehension(iter(iterator_expression))
When you make
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
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
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
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
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-
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
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
15 matches
Mail list logo