[Python-ideas] Re: PEP 584: Add + and += operators to the built-in dict class.

2019-10-17 Thread Brandt Bucher
Anders Hovmöller wrote: > It would have been better with a dedicated concat operator I think but just a > little bit better. Interesting little side note, for anyone who doesn't already know: at the C level, Python objects have two ways of implementing addition and multiplication. The first is

[Python-ideas] Re: PEP 584: Add + and += operators to the built-in dict class.

2019-10-17 Thread Anders Hovmöller
> On 17 Oct 2019, at 22:44, Steven D'Aprano wrote: > > On Thu, Oct 17, 2019 at 01:42:54PM +0200, Anders Hovmöller wrote: > >> The multiply a list/string thing is a big mistake imo. You almost >> never use it so the cost of not having it is almost nothing while the >> cost of having type err

[Python-ideas] Re: RFC: PEP xxx: Python Compatibility Version

2019-10-17 Thread Brendan Barnwell
On 2019-10-17 18:02, Victor Stinner wrote: Hi, I propose the following PEP to add sys.set_python_compat_version(version) to introduce a partial compatibility with Python 3.8 in the next Python 3.9 version. I also propose this PEP in a pull request: https://github.com/python/peps/pull/1209 (Plea

[Python-ideas] Re: RFC: PEP xxx: Python Compatibility Version

2019-10-17 Thread Dong-hee Na
I re-read your proposal. Please ignore my suggestion. :) I misunderstood core concept of your proposal :) 2019년 10월 18일 (금) 오전 10:19, Victor Stinner 님이 작성: > > Hi, > > I propose the following PEP to add > sys.set_python_compat_version(version) to introduce a partial > compatibility with Python 3.8

[Python-ideas] Re: RFC: PEP xxx: Python Compatibility Version

2019-10-17 Thread Ethan Furman
On 10/17/2019 06:02 PM, Victor Stinner wrote: I propose the following PEP to add sys.set_python_compat_version(version) to introduce a partial compatibility with Python 3.8 in the next Python 3.9 version. -1 If possible, please try to read the whole PEP before replying. Done. TL;DR Besid

[Python-ideas] Re: RFC: PEP xxx: Python Compatibility Version

2019-10-17 Thread Dong-hee Na
The proposal looks awesome to me. Victor :) It could be out of scope for this proposal. How about adding APIs about compatibility implementation in this proposal? e.g compatibility_python_implementation usage will be sys.compatibility_python_implementation(('Cpython', 'PyPy', 'XXXPython')) We ca

[Python-ideas] Re: Add collections.abc.Struct as virtual base class of namedtuple classes and dataclass-decorated classes.

2019-10-17 Thread Andrew Barnert via Python-ideas
On Oct 17, 2019, at 16:03, Steve Jorgensen wrote: > > My thinking is that checking for type of `Struct` (or `Record` or whatever > name it has) is most useful in cases when the object is also identifiable as > a collection and is to disambiguate those that are primarily collections from > thos

[Python-ideas] RFC: PEP xxx: Python Compatibility Version

2019-10-17 Thread Victor Stinner
Hi, I propose the following PEP to add sys.set_python_compat_version(version) to introduce a partial compatibility with Python 3.8 in the next Python 3.9 version. I also propose this PEP in a pull request: https://github.com/python/peps/pull/1209 (Please avoid using the temporary PEP number until

[Python-ideas] Re: Add collections.abc.Struct as virtual base class of namedtuple classes and dataclass-decorated classes.

2019-10-17 Thread Steve Jorgensen
Eric V. Smith wrote: > On 10/17/2019 2:36 PM, Steve Jorgensen wrote: > > Andrew Barnert wrote: > > [snip] > > But meanwhile, you still haven’t given any > > reason why Record would be useful. What > > exactly is it supposed to mean? When would you want to check it? What would > > you do with > > a

[Python-ideas] Re: PEP 584: Add + and += operators to the built-in dict class.

2019-10-17 Thread Christopher Barker
On Thu, Oct 17, 2019 at 5:33 AM Steven D'Aprano wrote: > On Thu, Oct 17, 2019 at 08:19:13AM -, Steve Jorgensen wrote: > > > Why the need for strictness of type for the operator? I get that it's > > analogous with the behavior for `list`, but I guess I'm also not sure > > why that should be st

[Python-ideas] Re: PEP 584: Add + and += operators to the built-in dict class.

2019-10-17 Thread Mike Miller
+1 Been waiting a decade+ for this. Too bad it didn't get into 3.8. Nice work on the PEP. -Mike p.s. A another mentioned this existing syntax does allow non-string keys: >>> d1 = dict(one=1, two=2) >>> d2 = {'three':3, 4:4} >>> >>> {**d1, **d2} {'one': 1, 'two': 2, 'three': 3, 4: 4

[Python-ideas] Re: PEP 584: Add + and += operators to the built-in dict class.

2019-10-17 Thread Steven D'Aprano
On Thu, Oct 17, 2019 at 02:08:56PM +0200, Anders Hovmöller wrote: > Well obviously never with literals. But most cases of multiplication > aren't with literals. So how can you get a type error when doing > > a*b > > is the real question. Actually, the real question is, why are you using such c

[Python-ideas] Re: PEP 584: Add + and += operators to the built-in dict class.

2019-10-17 Thread Steven D'Aprano
On Thu, Oct 17, 2019 at 01:42:54PM +0200, Anders Hovmöller wrote: > The multiply a list/string thing is a big mistake imo. You almost > never use it so the cost of not having it is almost nothing while the > cost of having type errors propagate beyond the point where they > happened is big. I

[Python-ideas] Re: PEP 584: Add + and += operators to the built-in dict class.

2019-10-17 Thread Steven D'Aprano
On Thu, Oct 17, 2019 at 12:41:29AM -0700, Andrew Barnert via Python-ideas wrote: > Less trivial, but maybe dismissible: it says one of the authors is > going to write another PEP later to add the full complement of set > operators to dict. It says that one of the authors is *interested* in writ

[Python-ideas] Re: Add collections.abc.Struct as virtual base class of namedtuple classes and dataclass-decorated classes.

2019-10-17 Thread Eric V. Smith
On 10/17/2019 2:36 PM, Steve Jorgensen wrote: Andrew Barnert wrote: [snip] But meanwhile, you still haven’t given any reason why Record would be useful. What exactly is it supposed to mean? When would you want to check it? What would you do with an object only if you know it’s a Record? This i

[Python-ideas] Re: PEP 584: Add + and += operators to the built-in dict class.

2019-10-17 Thread Chris Angelico
On Fri, Oct 18, 2019 at 6:06 AM Anders Hovmöller wrote: > > > On 17 Oct 2019, at 20:37, Chris Angelico wrote: > > > > On Fri, Oct 18, 2019 at 5:25 AM Anders Hovmöller > > wrote: > >> > >> No. The reason I don't know is because this is a hypothetical example. In > >> real code I would "know" B

[Python-ideas] Re: PEP 584: Add + and += operators to the built-in dict class.

2019-10-17 Thread Steve Jorgensen
Steven D'Aprano wrote: > On Thu, Oct 17, 2019 at 08:19:13AM -, Steve Jorgensen wrote: > > Why the need for strictness of type for the operator? > > I get that it's > > analogous with the behavior for list, but I guess I'm also not sure > > why that should be strict. > > (1) Follow the precede

[Python-ideas] Re: PEP 584: Add + and += operators to the built-in dict class.

2019-10-17 Thread Anders Hovmöller
> On 17 Oct 2019, at 20:37, Chris Angelico wrote: > > On Fri, Oct 18, 2019 at 5:25 AM Anders Hovmöller wrote: >> >> >> On 17 Oct 2019, at 17:07, Andrew Barnert wrote: >>> >>> On Oct 17, 2019, at 05:08, Anders Hovmöller wrote: Well obviously never with literals. But most

[Python-ideas] Re: PEP 584: Add + and += operators to the built-in dict class.

2019-10-17 Thread Chris Angelico
On Fri, Oct 18, 2019 at 5:25 AM Anders Hovmöller wrote: > > > > > On 17 Oct 2019, at 17:07, Andrew Barnert wrote: > > > > On Oct 17, 2019, at 05:08, Anders Hovmöller wrote: > >> > >> Well obviously never with literals. But most cases of multiplication > >> aren't with literals. So how can you

[Python-ideas] Re: Add collections.abc.Struct as virtual base class of namedtuple classes and dataclass-decorated classes.

2019-10-17 Thread Steve Jorgensen
Andrew Barnert wrote: [snip] > But meanwhile, you still haven’t given any reason why Record would be useful. > What > exactly is it supposed to mean? When would you want to check it? What would > you do with an > object only if you know it’s a Record? > This isn’t like checking for a POD type in

[Python-ideas] Re: PEP 584: Add + and += operators to the built-in dict class.

2019-10-17 Thread Anders Hovmöller
> On 17 Oct 2019, at 17:07, Andrew Barnert wrote: > > On Oct 17, 2019, at 05:08, Anders Hovmöller wrote: >> >> Well obviously never with literals. But most cases of multiplication aren't >> with literals. So how can you get a type error when doing >> >> a*b >> >> is the real question. A

[Python-ideas] Re: PEP 584: Add + and += operators to the built-in dict class.

2019-10-17 Thread Brandt Bucher
Andrew Barnert wrote: > Minor nit: the formatting is broken in some of the examples of candidates. The > first one I noticed is the last Sphinx one. Thanks for spotting those! I'll fix them. > Less trivial, but maybe dismissible: it says one of the authors is going to > write > another PEP later

[Python-ideas] Re: Add collections.abc.Struct as virtual base class of namedtuple classes and dataclass-decorated classes.

2019-10-17 Thread Andrew Barnert via Python-ideas
On Oct 17, 2019, at 01:35, Steve Jorgensen wrote: > > Along with this idea, maybe `namedtuple` should became a type (not just a > callable as it is now) for classes produced by calling `namedtuple()`. The > `namedtuple` type could in turn inherit from `tuple` and from `Record` (or > `Struct` o

[Python-ideas] Re: PEP 584: Add + and += operators to the built-in dict class.

2019-10-17 Thread Andrew Barnert via Python-ideas
On Oct 17, 2019, at 05:08, Anders Hovmöller wrote: > > Well obviously never with literals. But most cases of multiplication aren't > with literals. So how can you get a type error when doing > > a*b > > is the real question. And the answer is now obvious: any time the programmer > thinks a

[Python-ideas] Re: PEP 584: Add + and += operators to the built-in dict class.

2019-10-17 Thread Anders Hovmöller
> On 17 Oct 2019, at 14:26, Chris Angelico wrote: > > On Thu, Oct 17, 2019 at 11:08 PM Anders Hovmöller > wrote: >> >> So how can you get a type error when doing >> >> a*b >> >> is the real question. And the answer is now obvious: any time the >> programmer thinks a and b are numbers bu

[Python-ideas] Re: Add collections.abc.Struct as virtual base class of namedtuple classes and dataclass-decorated classes.

2019-10-17 Thread Ricky Teachey
> > Along with this idea, maybe `namedtuple` should became a type (not just a > callable as it is now) for classes produced by calling `namedtuple()`. The > `namedtuple` type could in turn inherit from `tuple` and from `Record` (or > `Struct` or whatever name is decided for that). > See Raymond He

[Python-ideas] Re: PEP 584: Add + and += operators to the built-in dict class.

2019-10-17 Thread Chris Angelico
On Thu, Oct 17, 2019 at 11:08 PM Anders Hovmöller wrote: > > So how can you get a type error when doing > > a*b > > is the real question. And the answer is now obvious: any time the programmer > thinks a and b are numbers but they are not. > If you start with the assumption that multiplication

[Python-ideas] Re: PEP 584: Add + and += operators to the built-in dict class.

2019-10-17 Thread Anders Hovmöller
> On 17 Oct 2019, at 13:46, Chris Angelico wrote: > > On Thu, Oct 17, 2019 at 10:42 PM Anders Hovmöller > wrote: >> On 17 Oct 2019, at 13:26, Chris Angelico wrote: >>> >>> Equally subjective, of course, but I prefer to be able to use >>> operators. There's a good reason that we use m

[Python-ideas] Re: PEP 584: Add + and += operators to the built-in dict class.

2019-10-17 Thread Chris Angelico
On Thu, Oct 17, 2019 at 10:42 PM Anders Hovmöller wrote: > > > On 17 Oct 2019, at 13:26, Chris Angelico wrote: > > > > Equally subjective, of course, but I prefer to be able to use > > operators. There's a good reason that we use mathematical symbols for > > non-numeric data types already (adding

[Python-ideas] Re: PEP 584: Add + and += operators to the built-in dict class.

2019-10-17 Thread Anders Hovmöller
> On 17 Oct 2019, at 13:26, Chris Angelico wrote: > > On Thu, Oct 17, 2019 at 8:54 PM Inada Naoki wrote: >> >> I think this PEP is very relating to language design philosophy. >> >> (a) Overload operator heavily for convenience. >> >> (b) Prefer methods over operators. Set a high bar for

[Python-ideas] Re: PEP 584: Add + and += operators to the built-in dict class.

2019-10-17 Thread Chris Angelico
On Thu, Oct 17, 2019 at 8:54 PM Inada Naoki wrote: > > I think this PEP is very relating to language design philosophy. > > (a) Overload operator heavily for convenience. > > (b) Prefer methods over operators. Set a high bar for > overloading operators on core types. > > I prefer (b) philosop

[Python-ideas] Re: PEP 584: Add + and += operators to the built-in dict class.

2019-10-17 Thread Inada Naoki
I think this PEP is very relating to language design philosophy. (a) Overload operator heavily for convenience. (b) Prefer methods over operators. Set a high bar for overloading operators on core types. I prefer (b) philosophy. And I don't think described usefulness is enough for adding th

[Python-ideas] Re: PEP 584: Add + and += operators to the built-in dict class.

2019-10-17 Thread Steven D'Aprano
On Thu, Oct 17, 2019 at 08:19:13AM -, Steve Jorgensen wrote: > Why the need for strictness of type for the operator? I get that it's > analogous with the behavior for `list`, but I guess I'm also not sure > why that should be strict. (1) Follow the precedent of existing operators. (2) It i

[Python-ideas] Re: Add collections.abc.Struct as virtual base class of namedtuple classes and dataclass-decorated classes.

2019-10-17 Thread Steve Jorgensen
Steve Jorgensen wrote: > I feel like this proposal is not quite right, but maybe the idea will provoke > some > thoughts about something similar that -would- be right. > The idea first came to me upon realizing that since namedtuple classes > have no special base class beyond tuple, there should b

[Python-ideas] Re: PEP 584: Add + and += operators to the built-in dict class.

2019-10-17 Thread Steve Jorgensen
Late to the game, I like the proposal a lot but have a couple of questions about it. Why the need for strictness of type for the operator? I get that it's analogous with the behavior for `list`, but I guess I'm also not sure why that should be strict. As a compromise in regard to strictness, wh

[Python-ideas] Re: PEP 584: Add + and += operators to the built-in dict class.

2019-10-17 Thread Josh Rosenberg
Notes on new PEP: The section on {**d1, **d2} claims "It is only guaranteed to work if the keys are all strings. If the keys are not strings, it currently works in CPython, but it may not work with other implementations, or future versions of CPython[2]." That's 100% wrong. You're mixing up the

[Python-ideas] Re: PEP 584: Add + and += operators to the built-in dict class.

2019-10-17 Thread Steve Jorgensen
Andrew Barnert wrote: > On Oct 17, 2019, at 00:22, Steve Jorgensen ste...@stevej.name wrote: > > Do you know if there is an existing proposal for > > subtraction of iterables from lists and tuples? > > Any existing proposal would be listed in PEP 0 if it’s a PEP, on > > bugs.python.org > if it doe

[Python-ideas] Re: PEP 584: Add + and += operators to the built-in dict class.

2019-10-17 Thread Andrew Barnert via Python-ideas
On Oct 17, 2019, at 00:22, Steve Jorgensen wrote: > > Do you know if there is an existing proposal for subtraction of iterables > from lists and tuples? Any existing proposal would be listed in PEP 0 if it’s a PEP, on bugs.python.org if it doesn’t need a PEP, or in a current thread in this lis

[Python-ideas] Re: PEP 584: Add + and += operators to the built-in dict class.

2019-10-17 Thread Andrew Barnert via Python-ideas
On Oct 16, 2019, at 22:35, Brandt Bucher wrote: > > At long last, Steven D'Aprano and I have pushed a second draft of PEP 584 > (dictionary addition): > > https://www.python.org/dev/peps/pep-0584/ Minor nit: the formatting is broken in some of the examples of candidates. The first one I notic

[Python-ideas] Re: PEP 584: Add + and += operators to the built-in dict class.

2019-10-17 Thread Steve Jorgensen
Brandt Bucher wrote: > At long last, Steven D'Aprano and I have pushed a second draft of PEP 584 > (dictionary > addition): > https://www.python.org/dev/peps/pep-0584/ > The accompanying reference implementation is on GitHub: > https://github.com/brandtbucher/cpython/tree/addiction Do you know if

[Python-ideas] Re: Add collections.abc.Struct as virtual base class of namedtuple classes and dataclass-decorated classes.

2019-10-17 Thread Steve Jorgensen
`Record` feels good to me as a name for this concept. ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived a