[Python-Dev] Re: About the new CFrame structure

2021-12-20 Thread Brandt Bucher
Just to clear up a quick point I made: > - PyFrameObject.f_back just gives you a dummy wrapper around the previous > frame object. > - It's not really useful for unwinding anything. That should read "previous InterpreterFrame", rather than "previous frame object". Also, everything I wrote

[Python-Dev] Re: About the new CFrame structure

2021-12-20 Thread Brandt Bucher
Hi Gabriele! > I hope you would indulge me in asking for some details about the new CFrame > structure, even in the form of existing literature (e.g. PEP) where the idea > behind it is explained. There isn't too much documentation on this, unfortunately (since these are all very unstable,

[Python-Dev] Re: Why doesn't peephole optimise away operations with fast locals?

2021-10-10 Thread Brandt Bucher
Guido van Rossum wrote: > What's exasperating to me about this whole discussion is that nobody has > shown any reason why this kind of code would be occurring in user code. > STORE_FAST x LOAD_FAST x seems that it must come from a user writing > x = x I think that would be LOAD_FAST(x)

[Python-Dev] Re: Why doesn't peephole optimise away operations with fast locals?

2021-10-10 Thread Brandt Bucher
I can think of two reasons. The first reason is that this operation *does* have a side-effect: if a fast local is unbound, the load will raise a NameError! def f(): x # This should always raise. x = None # This makes x a fast local. The second reason is one that Guido already

[Python-Dev] Re: PEP 654 except* formatting

2021-10-06 Thread Brandt Bucher
Łukasz Langa wrote: > Joking aside, since we allow any expression after 'except' 'group' then this > is indeed ambiguous. In theory! The ambiguity with function calls, though, is probably a dealbreaker: except group (E1, E2) as e: … except group(E1, E2) as e: … See my other message for an

[Python-Dev] Re: PEP 654 except* formatting

2021-10-06 Thread Brandt Bucher
Łukasz Langa wrote: > Joking aside, since we allow any expression after 'except' 'group' then this > is indeed ambiguous. In theory! Another option (to remove the ambiguity) could be to move the “group” after the expression. Bonus points for reading more clearly: except MemoryError group as e:

[Python-Dev] Re: PEP 654 except* formatting

2021-10-03 Thread Brandt Bucher
Łukasz Langa wrote: > My idea is this: > try: > ... > except group E as e: > ... > except group E1, T2 as e: > ... > Should be doable given the magical match-case contextual keywords precedent. > This looks nice and is explicit, since you will always get an ExceptionGroup > instance

[Python-Dev] Re: PEP 654 except* formatting

2021-10-03 Thread Brandt Bucher
Irit Katriel wrote: > It is also not too late to opt for a completely different syntax if a better > one is suggested. Honestly, I’ve never been a fan of the PEP’s proposed star syntax. If we’re okay adding a soft keyword, though, something like “except each” could help communicate the meaning

[Python-Dev] Re: Should the definition of an "(async) iterator" include __iter__?

2021-09-14 Thread Brandt Bucher
Guido van Rossum wrote: > TBH I don't think there is an *actual* problem here. I think it's just > about choosing the right wording for the glossary (which IMO does not have > status as a source of truth anyway). Good point. I'm probably approaching this from the wrong angle (by trying to "fix"

[Python-Dev] Re: Should the definition of an "(async) iterator" include __iter__?

2021-09-14 Thread Brandt Bucher
Guido van Rossum wrote: > On Tue, Sep 14, 2021 at 3:49 PM Brandt Bucher brandtbuc...@gmail.com > wrote: > > I think it's also worth noting that a missing "`__iter__` that returns > > self" is trivial to recover from... just use a new reference to the > > iterator

[Python-Dev] Re: Should the definition of an "(async) iterator" include __iter__?

2021-09-14 Thread Brandt Bucher
I think it's also worth noting that a missing "`__iter__` that returns self" is trivial to recover from... just use a new reference to the iterator instead. The overhead of a method call for this convention almost seems silly. What worries me most about changing the current "requirement" is

[Python-Dev] Re: PEP 467 feedback from the Steering Council

2021-09-09 Thread Brandt Bucher
Brandt Bucher wrote: > You can even get creative and use the dedicated “pistol” operator… Ah, wait, ignore this example. I got the chr and ord behavior flipped in my head. Brandt ___ Python-Dev mailing list -- python-dev@python.org To unsubscribe s

[Python-Dev] Re: PEP 467 feedback from the Steering Council

2021-09-09 Thread Brandt Bucher
Steven D'Aprano wrote: > TIL :-) > How have I never noticed to_bytes until now? o_O I’m going to go out on a limb here: because it’s rarely ever needed? I mean, the proposed bchr() functionality is crazy simple to implement yourself if you actually *do* need it. You can even get creative and

[Python-Dev] Re: PEP 467 feedback from the Steering Council

2021-09-08 Thread Brandt Bucher
Steven D'Aprano wrote: > To me, it sounds like should be the opposite of int.from_bytes. > >>> int.from_bytes(b'Hello world', 'little') > 121404708502361365413651784 > >>> bytes.from_int(121404708502361365413651784, 'little') > # should return b'Hello world' > If that's not the API

[Python-Dev] Re: Problems with dict subclassing performance

2021-08-18 Thread Brandt Bucher
Marco Sulla wrote: > I remember the BDFL said in a post […] Really trying not to get involved, but for anybody still reading: Marco is seriously misquoting somebody here. The actual quote is “too many cooks”.

[Python-Dev] Re: Critique of PEP 657 -- Include Fine Grained Error Locations in Tracebacks

2021-05-17 Thread Brandt Bucher
Ethan Furman wrote: > On 5/17/2021 6:13 AM, Mark Shannon wrote: > > Where i1, i2 are integers and s1 is a string. > > > i1 + i2 + s1 > > > Wouldn't the carets just be under the i2 + s1 portion? I don't think so, since this is executed as `((i1 + i2) + s1)`. Mark's carets look

[Python-Dev] Re: str() vs format(): trivia question

2021-04-20 Thread Brandt Bucher
It has always bugged me that for Enums mixed in with int or str (a common pattern in my code), `f"{MyEnum.X}"` is not the same as `str(MyEnum.X)`. I'd be happy to see it changed! ___ Python-Dev mailing list -- python-dev@python.org To unsubscribe send

[Python-Dev] Re: Request for comments on final version of PEP 653 (Precise Semantics for Pattern Matching)

2021-04-06 Thread Brandt Bucher
Hi Mark. Thanks for your reply, I really appreciate it. Mark Shannon said: > My intention, and I apologize for not making this clearer, was not to > denigrate your work, but to question the implications of the term "reference". > > Calling something a "reference" implementation suggests that

[Python-Dev] Re: Request for comments on final version of PEP 653 (Precise Semantics for Pattern Matching)

2021-04-03 Thread Brandt Bucher
Mark Shannon said: > I was relying on the "reference" implementation, which is also in the PEP. Can you please stop putting scare quotes around "reference implementation"? You've done it twice now, and it's been a weekend-ruiner for me each time. I've put months of work into writing and

[Python-Dev] Re: Request for comments on final version of PEP 653 (Precise Semantics for Pattern Matching)

2021-04-02 Thread Brandt Bucher
Mark Shannon wrote: > On 02/04/2021 7:19 am, Brandt Bucher wrote: > > I agree that self-matching classes should absolutely allow keyword matches. > > I had no idea the PEP forbade it. > PEP 634 allows it. PEP 634 says: > For a number of built-in types (specified below)

[Python-Dev] Re: Request for comments on final version of PEP 653 (Precise Semantics for Pattern Matching)

2021-04-02 Thread Brandt Bucher
Guido van Rossum wrote: > Well, now I have egg on my face, because the current implementation does > reject multiple occurrences of the same identifier in __match_args__. We > generate an error like "TypeError: C() got multiple sub-patterns for > attribute 'a'". However, I cannot find this

[Python-Dev] Re: Request for comments on final version of PEP 653 (Precise Semantics for Pattern Matching)

2021-03-31 Thread Brandt Bucher
Guido van Rossum wrote: > On Wed, Mar 31, 2021 at 2:14 PM Brandt Bucher brandtbuc...@gmail.com > wrote: > > (One change from my last email: it doesn't allow `__match_map__` / > > `__match_seq__` to be set to `False`... only `True`. This prevents some > > otherwise tricky m

[Python-Dev] Re: Request for comments on final version of PEP 653 (Precise Semantics for Pattern Matching)

2021-03-31 Thread Brandt Bucher
>> - Add new `__match_seq__` and `__match_map__` special attributes, >> corresponding to new public `Py_TPFLAGS_MATCH_SEQ` and >> `Py_TPFLAGS_MATCH_MAP` flags for use in `tp_flags`. When Python classes are >> defined with one or both of these attributes set to a boolean value, >>

[Python-Dev] Re: Request for comments on final version of PEP 653 (Precise Semantics for Pattern Matching)

2021-03-30 Thread Brandt Bucher
Hi Mark. I've spoken with Guido, and we are willing to propose the following amendments to PEP 634: - Require `__match_args__` to be a tuple. - Add new `__match_seq__` and `__match_map__` special attributes, corresponding to new public `Py_TPFLAGS_MATCH_SEQ` and `Py_TPFLAGS_MATCH_MAP` flags

[Python-Dev] Re: Request for comments on final version of PEP 653 (Precise Semantics for Pattern Matching)

2021-03-30 Thread Brandt Bucher
Overall, I am still uncomfortable with PEP 653, and would probably not support its acceptance. Although it has thankfully become a much less radical proposal than it was a few weeks ago (thanks, Mark, for your attention to our feedback), I feel that the rules it binds implementations to are

[Python-Dev] Re: PEP 653: Precise Semantics for Pattern Matching

2021-02-19 Thread Brandt Bucher
Oscar Benjamin wrote: > Under PEP 634 in general, for any class C, a pattern C(x) matches an object > C(x, y) and there's no way for C to override that. To me that is sufficiently > unintuitive in the abstract that no example is really needed to see where > there is room for improvement. We

[Python-Dev] Re: PEP 653: Precise Semantics for Pattern Matching

2021-02-18 Thread Brandt Bucher
Brandt Bucher wrote: > For a pattern with no positional subpatterns, such as like `C()` or `C(x=x, > y=y, z=z)`: ... > It also appears that we lose a lot of expressive "idioms" by requiring > `__attributes__` to be complete. > This also means that matching classes li

[Python-Dev] Re: PEP 653: Precise Semantics for Pattern Matching

2021-02-18 Thread Brandt Bucher
Thanks for taking the time to work on this, Mark. Overall, I'm skeptical of this proposal. It seems like it takes a lot of "simple" things and makes them quite complex, and takes many "static" things and makes them quite dynamic. I feel that it also misrepresents certain aspects of PEP 634.

[Python-Dev] Re: PEP 642 v2: Explicit constraint patterns *without* question marks in the syntax

2020-11-13 Thread Brandt Bucher
Paul Sokolovsky wrote: > Use punctuation ("sigils") to mark as-binding terms. This choice still seems > to be under-considered. (As in: it doesn't seem like many people, including > the PEP authors, tried to say "indeed, what if?" and feel thru it. I mean, > try really hard. I trust the "gang

[Python-Dev] Re: PEP 642: Constraint Pattern Syntax for Structural Pattern Matching

2020-11-02 Thread Brandt Bucher
Glenn Linderman wrote: > So what _is_ the syntax for "a tuple of two equal values" ? If you’re asking about PEP 634: ``` case x, y if x == y: ``` Which is much clearer, in my opinion. ___ Python-Dev mailing list -- python-dev@python.org To unsubscribe

[Python-Dev] Re: Thoughts on PEP 634 (Structural Pattern Matching)

2020-10-30 Thread Brandt Bucher
> Can we discuss whether we want pattern matching in Python and the broader > semantics first, before dealing with low level details? This is a huge step backward. These discussions have already taken place, over the last 10 years. Here's just a sampling: -

[Python-Dev] Re: docs: I'd like new features to references their PEPs

2020-09-14 Thread Brandt Bucher
Agreed. To prevent the docs from going stale, the "Originally proposed in :pep:`XXX`." wording should probably be used for *all* of the new links, not just the ones that are currently out-of-date. Depending on the scope of these changes, we could also just consider adding a new ".. pepadded::

[Python-Dev] Re: Deferred, coalescing, and other very recent reference counting optimization

2020-09-03 Thread Brandt Bucher
Tim Peters wrote: > `zip` then creates `n` 2-tuple objects, each of which lives only long enough > to be unpacked into `x` and `y`... With "immediate" reclamation of garbage > via refcounting, memory use is trival regardless of how large `n` is, as > CPython reuses the same heap space over &

[Python-Dev] Re: PEP 622 version 2 (Structural Pattern Matching)

2020-07-10 Thread Brandt Bucher
Federico Salerno wrote: > Is there anything (bar tradition or other subjective arguments) that speaks > in favour of this, especially in light of the fact that having the same > indentation level would also solve other problems? ...if anyone made an > argument against it I must have missed it:

[Python-Dev] Re: PEP 622 version 2 (Structural Pattern Matching)

2020-07-08 Thread Brandt Bucher
Ethan Furman wrote: > Why is this no longer an issue? My apologies if I missed it in the PEP. This problem was an artifact of the default `object.__match__` implementation, which allowed one positional argument by default when `__match_args__` was missing or `None`. Since we've removed

[Python-Dev] Re: PEP 622: Structural Pattern Matching -- followup

2020-07-08 Thread Brandt Bucher
Inada Naoki wrote: > Since this is very new system, can we have some restriction to allow > aggressive optimization than regular Python code? The authors were just discussing a related question yesterday (more specifically, can the compiler fold `C() | C()` -> `C( | )`). The answer we arrived

[Python-Dev] Re: Why does _ need to be special ?

2020-07-08 Thread Brandt Bucher
Henk-Jaap Wagenaar wrote: > The not binding is there only to allow the main way in which "_" is special > in match/case: ... The non-binding behavior is useful in other ways: match range(HUGE_INT): case [*_, last]: print(last) ___

[Python-Dev] Re: PEP 622 railroaded through?

2020-07-04 Thread Brandt Bucher
Since I took it upon myself to implement PEP 622, I just have a few thoughts to add to the other excellent responses here. Hopefully these will help clarify that the intent is not to "railroad" anything. Rob Cliffe wrote: > PEP 622 only seems to have been presented to the Python community only

[Python-Dev] Re: PEP 622 (match statement) playground

2020-07-01 Thread Brandt Bucher
Walter Dörwald wrote: > This looks strange to me. In all other cases of variable lookup the global > variable z would be found. The next case assigns to z, making z local to whereis. This is consistent with python's existing scoping rules (for example, try rewriting this as the equivalent

[Python-Dev] Re: PEP 622: Structural Pattern Matching -- followup

2020-06-25 Thread Brandt Bucher
Ethan Furman wrote: > Ouch. That seems like a pretty serious drawback. Will this issue be > resolved? It's currently being revisited. Realistically, I'd imagine that we either find some straightforward way of opting-in to the current default behavior (allowing one arg to be positionally

[Python-Dev] Re: PEP 622: Structural Pattern Matching -- followup

2020-06-25 Thread Brandt Bucher
Pablo Galindo Salgado wrote: > ...users can do a positional match against the proxy with a name pattern: > > match input: > case datetime.date(dt): > print(f"The date {dt.isoformat()}" > > ...if 'datetime.date' were updated to implement a non-default __match_args__, > allowing

[Python-Dev] Re: PEP 622: Structural Pattern Matching

2020-06-24 Thread Brandt Bucher
Guido van Rossum wrote: > So why not .get(key, )? You can reuse the sentinel, and this way > it's a single call instead of two -- e.g. the code in Mapping implements both > __contains__() and get() by calling __getitem__() and catching KeyError. Good point. Another option I've considered is

[Python-Dev] Re: PEP 622: Structural Pattern Matching

2020-06-24 Thread Brandt Bucher
Guido van Rossum wrote: > IIUC the pattern matching uses either .get(key, ) or > .__contains__(key) followed by .__getitem__(key). Neither of those will > auto-add the item to a defaultdict (and the Mapping protocol supports both). > @Brandt: what does your implementation currently do? Do you

[Python-Dev] Re: Accepting PEP 618: zip(strict=True)

2020-06-16 Thread Brandt Bucher
Woo! Many thanks to Ram for the idea, Antoine for sponsoring, Guido for PEP-Delegating, and everyone on -Ideas and -Dev for the spirited discussion and review. Brandt ___ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to

[Python-Dev] Re: PEP 584 underspecified

2020-05-19 Thread Brandt Bucher
Maybe I'm missing something here. The PEP specifically says: > Similarly, the iteration order of the key-value pairs in the dictionary will > follow the same semantics as the examples above, with each newly added key > (and its value) being appended to the current sequence. That seems

[Python-Dev] Re: PEP 618: Add Optional Length-Checking To zip

2020-05-15 Thread Brandt Bucher
In the last 24 hours, this thread has grown a bit beyond my capacity to continue several different lines of discussion with each individual. I count 22 messages from 14 different people since my last reply, and I assure you that I've carefully read each response and am considering them as I

[Python-Dev] Re: PEP 618: Add Optional Length-Checking To zip

2020-05-15 Thread Brandt Bucher
Ethan Furman wrote: > Can you do those with _pydecimal? If performance were an issue anywhere I > would expect to see it with number crunching. No difference, probably because those methods look like they spend most of their time doing string manipulation: ``` $ export PYPERFSETUP='from

[Python-Dev] Re: PEP 618: Add Optional Length-Checking To zip

2020-05-14 Thread Brandt Bucher
Ethan Furman wrote: > So half of your examples are actually counter-examples. I claimed to have found "dozens of other call sites in Python's standard library and tooling where it would be appropriate to enable this new feature". You asked for references, and I provided two dozen cases of

[Python-Dev] Re: PEP 618: Add Optional Length-Checking To zip

2020-05-12 Thread Brandt Bucher
Thanks for all of your feedback. Antoine Pitrou wrote: > I'm not sure what the iters bring here. The snippet would be more readable > without, IMHO. Good point. I was trying to demonstrate that it works with iterators, but I agree it's clearer to just use the lists here. Ethan Furman wrote:

[Python-Dev] PEP 618: Add Optional Length-Checking To zip

2020-05-10 Thread Brandt Bucher
I have pushed a second draft of PEP 618: https://www.python.org/dev/peps/pep-0618 Please let me know what you think – I'd love to hear any new feedback that hasn't yet been addressed in the PEP! Brandt ___ Python-Dev mailing list --

[Python-Dev] Re: Question about bytecode stability

2020-04-05 Thread Brandt Bucher
> The best way to look at this is to consider how long a .pyc file is valid. > They're currently named something like __pycache__/modulename.cpython-38.pyc > which is a fairly clear indication that the cached compiled module should be > valid for any CPython 3.8.x release. Perhaps an even

[Python-Dev] Re: PEP 614 accepted

2020-03-04 Thread Brandt Bucher
Welcome Bhavani! This is only my second PEP, but I'm sure somebody will correct me if I'm wrong! Basically, the next steps are: - Mark the PEP as "Accepted": https://github.com/python/peps/commit/841188a45f17f0252267f016d7b2f11ac27c5aa1 - Review and merge the implementation/tests:

[Python-Dev] Re: PEP 614 accepted

2020-03-03 Thread Brandt Bucher
Thanks to Guido for sponsoring, and to the SC for their acceptance! Brandt ___ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/

[Python-Dev] Re: Accepting PEP 584: Add Union Operators To dict

2020-02-27 Thread Brandt Bucher
Thanks for your response Serhiy. > Yes, but this is a different thing. You must to implement new __or__ in a > subclass to make the behavior of d1 | d2 be different from {**d1, **d2}. Really? I'm sorry, but this doesn't feel like a real argument to me. There was no clear compatible path

[Python-Dev] Re: Accepting PEP 584: Add Union Operators To dict

2020-02-24 Thread Brandt Bucher
> Are these three cookie classes sufficiently popular that we need to support > `|` on them? I don't have much experience with `http`, so I figured I'd open a BPO issue and let the relevant folks make the call. The main reason I'm considering these is that `Morsel` was updated back in 3.5 with

[Python-Dev] Re: PEP 614: Relaxing Grammar Restrictions On Decorators

2020-02-22 Thread Brandt Bucher
Happy to help. Since it doesn't seem like anybody has issues with the PEP, and the PR looks solid, I think I'll contact the Steering Council about moving this forward. Brandt ___ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an

[Python-Dev] Re: Accepting PEP 584: Add Union Operators To dict

2020-02-22 Thread Brandt Bucher
> we'll also want to look at collections.UserDict, collections.ChainMap, and > types.MappingProxyType. UserDict has already been updated in the PR (it has tests that fail if it doesn't have all of dict's methods). I'll look into the others... thanks for reminding me! > collections.Mapping and

[Python-Dev] Re: Accepting PEP 584: Add Union Operators To dict

2020-02-22 Thread Brandt Bucher
Just to follow up on this, here are the subclasses I've found. Should be updated: - collections.OrderedDict - collections.defaultdict - http.cookies.BaseCookie - http.cookies.Morsel - http.cookies.SimpleCookie Don’t think so: - typing.TypedDict Already defines the operator: -

[Python-Dev] Re: Three trivial PRs from first-timers in need of merging!

2020-02-21 Thread Brandt Bucher
All of these have been landed. Thanks, everybody! ___ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at

[Python-Dev] Three trivial PRs from first-timers in need of merging!

2020-02-20 Thread Brandt Bucher
Hi everybody! I've found a handful of trivial PRs from new contributors that have gone un-core-reviewed since November. CLAs are signed, tests are passing, and I've verified the quality and correctness of each one. If anybody has a few spare minutes to merge these, I know that it would make

[Python-Dev] PEP 614: Relaxing Grammar Restrictions On Decorators

2020-02-18 Thread Brandt Bucher
PEP 614 has recently completed a round of review on Python-Ideas: https://www.python.org/dev/peps/pep-0614/ It proposes that the current decorator syntax restrictions be relaxed to allow any valid expression. Nobody has raised any objections, but I wanted to gather more feedback here prior to

[Python-Dev] Re: Accepting PEP 584: Add Union Operators To dict

2020-02-18 Thread Brandt Bucher
> In particular, you may want to update the implementations of defaultdict and > ordereddict. (are there others?) I have a checklist for PEP 584 follow-up PRs I'm planning to make after (and if) it is accepted. typeshed stubs, docs, and `defaultdict` were on it. I'll add `OrderedDict` as well

[Python-Dev] Re: Accepting PEP 584: Add Union Operators To dict

2020-02-18 Thread Brandt Bucher
> I am accepting this PEP. Congratulations Steven and Brandt! Thank you for your guidance, especially the suggestions late last year. And thanks Steven for taking me on as a co-author and shaping the bulk of the proposal. > Hm, the PEP should probably also link to that PR rather than to

[Python-Dev] Re: PEP 584: Add Union Operators To dict

2020-02-16 Thread Brandt Bucher
> So can we just finish PEP 584 without the .copy() call? Sounds good. I’ll update the implementation and open a PR to the PEPs repo later tonight. Thanks everybody! ___ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to

[Python-Dev] Re: PEP 584: Add Union Operators To dict

2020-02-16 Thread Brandt Bucher
After a few days of thinking and experimenting, I’ve been convinced that `copy` (and also `__copy__`) is not the right protocol for what we want to do here. I believe that 584 can likely continue without subclass-preserving behavior, but that better behavior could perhaps could be added to

[Python-Dev] Re: PEP 584: Add Union Operators To dict

2020-02-06 Thread Brandt Bucher
> > We already have an API for copying a dict (dict.copy). I still fail to see > > problem with using a method that doesn't start and end with underscores, > > other than that we "haven't done it". > > Before Python 3.0, iterators had a next() method, and that was explicitly and > consciously

[Python-Dev] Re: PEP 584: Add Union Operators To dict

2020-02-06 Thread Brandt Bucher
Sorry Paul, I sent my reply too soon. I see what you're saying, and I'm pretty firmly -1 on reinventing (or importing) copy.copy. We already have an API for copying a dict (dict.copy). I still fail to see problem with using a method that doesn't start and end with underscores, other than that

[Python-Dev] Re: PEP 584: Add Union Operators To dict

2020-02-06 Thread Brandt Bucher
> but I think the desired semantics can all be achieved using only magic > methods on the objects themselves Hm. So, just to clarify, you're suggesting we use `__copy__`, if it exists? Interesting... ___ Python-Dev mailing list --

[Python-Dev] Re: PEP 584: Add Union Operators To dict

2020-02-06 Thread Brandt Bucher
> It would create an exception of two rules: I don't think these are "rules", I think they're just "the way things are". If I'm subclassing `dict`, and I see in the docs something to the effect of: > By default, `dict` subclasses will return `dict` objects for `|` operations. > To force the

[Python-Dev] Re: PEP 584: Add Union Operators To dict

2020-02-06 Thread Brandt Bucher
> I see this asymmetry between the | and |= mentioned a few times in the PEP, > but I don't see any rationale other than "the authors have decided". I agree that this probably deserves to be addressed. I can't speak for Steven, but I know that my motivation here is to restrict `|` in order to

[Python-Dev] Re: Clarification of unpacking semantics.

2020-02-06 Thread Brandt Bucher
> We should fix that (by reverting to 3.8.1 behaviour) before 3.8.2 gets > released. The commits which changed the behavior were bytecode/compiler changes that only went to master. I don't think they are present on any other branches. ___ Python-Dev

[Python-Dev] Re: PEP 584: Add Union Operators To dict

2020-02-06 Thread Brandt Bucher
One issue that's come up during PR review with Guido and Serhiy is, when evaluating `a | b`, whether or not the default implementation should call an overridden `copy()` method on `a` in order to create an instance of the correct subclass (rather than a plain-ol' `dict`). For example,

[Python-Dev] Clarification of unpacking semantics.

2020-02-05 Thread Brandt Bucher
Commits 13bc139 and 8a4cd70 introduced subtle changes in the evaluation logic of unpacking operations. Previously, all elements were evaluated prior to being collected in a container. Now, these operations are interleaved. For example, the code `[*a, *b]` used to evaluate in the order `a` ->

[Python-Dev] Re: PEP 584: Add Union Operators To dict

2020-02-05 Thread Brandt Bucher
> I have one suggestion: Wouldn't it be useful for these operators to also > accept sets (functionally acting like a dict with None for all values)? > Why None? Why not 0, or False, or 42? This sort of thing belongs more in a > function or method, IMHO. Well, in their defense, None is the

[Python-Dev] Re: PEP 584: Add Union Operators To dict

2020-02-04 Thread Brandt Bucher
It already has a PR open against master, with all tests passing: https://github.com/python/cpython/pull/12088 Sorry about the messy history - this proposal has changed significantly several times over the past year (at least as far as the implementation is concerned). At one point, both

[Python-Dev] PEP 584: Add Union Operators To dict

2020-02-04 Thread Brandt Bucher
Steven D'Aprano and I have pushed a third draft of PEP 584: https://www.python.org/dev/peps/pep-0584/ The accompanying reference implementation is on GitHub: https://github.com/brandtbucher/cpython/tree/addiction For those who have been following the discussions over the past year on

[Python-Dev] Re: Should set objects maintain insertion order too?

2019-12-27 Thread Brandt Bucher
> On Dec 27, 2019, at 19:48, Tim Peters wrote: > > So, ya, I've seen and implemented lots of work queues along these > lines - but an OrderedSet would be an "attractive nuisance" > (offhandedly appearing to solve a problem it doesn't actually > address): > > jobs = some_kind_of_queue() >

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

2019-10-25 Thread Brandt Bucher
Interesting that you bring this up. Just earlier this week I published the first version of a new package that lets you write compiled bytecode instructions inline with pure-Python syntax. The code's still a bit messy, being only a week old and all, but it works as advertised for CPython 3.6.2

[Python-Dev] Re: 4 first-time contributions that need core review.

2019-10-23 Thread Brandt Bucher
Thanks everybody for the quick response! These all now have core review (from Steering Council members, no less)! ___ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org

[Python-Dev] 4 first-time contributions that need core review.

2019-10-22 Thread Brandt Bucher
Hi all. There are a few *very simple* PRs from first-time contributors that have been sitting un-core-reviewed for several weeks. https://github.com/python/cpython/pull/16680: bpo-38419: fix "check-c-globals" path https://github.com/python/cpython/pull/16678: bpo-38421: Update email.utils

[Python-Dev] Re: EnHackathon 2019 - seeking core dev support

2019-10-22 Thread Brandt Bucher
Hi Lewis. I'm in the Pacific time zone. Barring any surprises (I'm getting married late next month), I can commit to being online in the morning (the last few hours of your business day), as well as during my normal business hours (late evening/night for you). Just tag "@brandtbucher" on any

[Python-Dev] Re: EnHackathon 2019 - seeking core dev support

2019-10-20 Thread Brandt Bucher
Hi Lewis. I'm a trigger (not a core developer), but I'd be happy to make myself available during that time for expedited PR reviews. Ideally, the core review / merge stage would be your only bottleneck then. I'm a bit busy next month though, so do you know the actual dates / time / time zones

[Python-Dev] Re: Migrate typing in builtin

2019-10-08 Thread Brandt Bucher
I’m a bit confused. For my own understanding: what’s stopping PyObject_IsInstance/PyObject_IsSubclass from just trying PyImport_GetModule("typing") here? If NULL, carry on. Otherwise, check the Union case. Brandt > On Oct 8, 2019, at 05:44, Philippe Prados wrote: > >  > Glups. > > I am