Re: [Python-Dev] Dataclasses and correct hashability

2018-02-05 Thread Nick Coghlan
On 5 February 2018 at 15:49, Guido van Rossum wrote: > My point is that once you have one of those patterns in place, changing your > code to avoid them may be difficult. And yet your code may treat the objects > as essentially immutable after the initialization phase (e.g. a

Re: [Python-Dev] Immutability vs. hashability

2018-02-05 Thread Antoine Pitrou
On Sun, 4 Feb 2018 14:31:06 -0800 Guido van Rossum wrote: > On Sun, Feb 4, 2018 at 11:59 AM, Chris Barker - NOAA Federal < > chris.bar...@noaa.gov> wrote: > > > I think the folks that are concerned about this issue are quite right > > — most Python users equate immutable and

[Python-Dev] Dataclasses and correct hashability

2018-02-05 Thread Kirill Balunov
> > On Sun, Feb 4, 2018, 9:50 PM Guido van Rossum > wrote: > > Looks like this is turning into a major flamewar regardless of what I say. > :-( > I really don't want to lose the ability to add a hash function to a > mutable dataclass by

Re: [Python-Dev] Dataclasses and correct hashability

2018-02-05 Thread Nathaniel Smith
On Sun, Feb 4, 2018 at 11:28 PM, Glenn Linderman wrote: > This is an interesting use case. I haven't got the internals knowledge to > know just how just different mutable and immutable classes and objects are > under the hood. But this use case makes me wonder if, even at

Re: [Python-Dev] Dataclasses and correct hashability

2018-02-05 Thread Glenn Linderman
On 2/5/2018 12:11 AM, Nathaniel Smith wrote: On Sun, Feb 4, 2018 at 11:28 PM, Glenn Linderman wrote: This is an interesting use case. I haven't got the internals knowledge to know just how just different mutable and immutable classes and objects are under the hood. But

Re: [Python-Dev] Dataclasses and correct hashability

2018-02-05 Thread Terry Reedy
On 2/5/2018 2:28 AM, Glenn Linderman wrote: This is an interesting use case. I haven't got the internals knowledge to know just how just different mutable and immutable classes and objects are under the hood. I believe there is no internal difference. An object is immutable if there is not

Re: [Python-Dev] Dataclasses and correct hashability

2018-02-05 Thread Ivan Levkivskyi
Just wanted to add my 5 cents here. I am a bit surprised how people are scared by adding `__hash__` to mutable classes. >From my experience it is quite normal, I was always thinking about `hash()` as hashing a _value_, and never as hashing _identity_, if I would need the latter, there is a

Re: [Python-Dev] Immutability vs. hashability

2018-02-05 Thread Steven D'Aprano
On Sun, Feb 04, 2018 at 09:18:25PM -0800, Guido van Rossum wrote: > The way I think of it generally is that immutability is a property of > types, while hashability is a property of values. That's a great way to look at it, thanks. -- Steve ___

Re: [Python-Dev] Dataclasses and correct hashability

2018-02-05 Thread Kirill Balunov
2018-02-05 20:47 GMT+03:00 Guido van Rossum : > If there's going to be an API for it, it should be in the class, not > something that mutates the class afterwards. > I apologize and don't want to make unnecessary noise. But the already selected design with decorator @dataclass

Re: [Python-Dev] Dataclasses and correct hashability

2018-02-05 Thread Guido van Rossum
Yes, that's what I meant -- "afterwards" meaning after the @dataclass decorator is applied. On Mon, Feb 5, 2018 at 11:09 AM, Kirill Balunov wrote: > > 2018-02-05 20:47 GMT+03:00 Guido van Rossum : > >> If there's going to be an API for it, it should be

Re: [Python-Dev] [RELEASE] Python 3.7.0b1 is now available for testing

2018-02-05 Thread Mike Miller
On 2018-01-31 17:34, Ned Deily wrote: Please see "What’s New In Python 3.7" for more information. Additional documentation for these features and for other changes will be provided during the beta phase. https://docs.python.org/3.7/whatsnew/3.7.html I see that the new classmethod

Re: [Python-Dev] Dataclasses and correct hashability

2018-02-05 Thread David Mertz
Absolutely I agree. 'unsafe_hash' as a name is clear warning to users. On Feb 4, 2018 10:43 PM, "Chris Barker" wrote: On Sun, Feb 4, 2018 at 11:57 PM, Gregory P. Smith wrote: > +1 using unsafe_hash as a name addresses my concern. > mine too -- anyone

Re: [Python-Dev] A minimal Python interpreter written in Python for experimenting with language changes

2018-02-05 Thread Steven D'Aprano
On Sat, Feb 03, 2018 at 11:45:15AM +0100, asrp wrote: > > Can you give an example of how you would do that? I don't mean the > > mechanism used, I mean how would a developer implement a new syntactic > > feature. Suppose I wanted to add a new clause to for...else, let's say: > > > > for ...

Re: [Python-Dev] A minimal Python interpreter written in Python for experimenting with language changes

2018-02-05 Thread rym...@gmail.com
https://refi64.com/posts/the-magic-of-rpython.html Note that this was written back when I used "like" and "really" in every sentence, and when I used to think that Python copied tuples (don't ask). On Feb 3, 2018 at 10:05 AM, > wrote: > Are you aware of pypy? > Yes, but I do not know it

Re: [Python-Dev] Immutability vs. hashability

2018-02-05 Thread Steven D'Aprano
On Mon, Feb 05, 2018 at 12:09:52AM -0600, Chris Barker wrote: > But a bit more detail -- I'm commenting on the API, not the capability - > that is, since users often equate hashable and immutability, they will > expect that if they say hash=True, then will get an immutable, and if they > say

Re: [Python-Dev] Dataclasses and correct hashability

2018-02-05 Thread Guido van Rossum
If there's going to be an API for it, it should be in the class, not something that mutates the class afterwards. On Mon, Feb 5, 2018 at 1:59 AM, Kirill Balunov wrote: > On Sun, Feb 4, 2018, 9:50 PM Guido van Rossum

Re: [Python-Dev] Dataclasses and correct hashability

2018-02-05 Thread Nick Coghlan
On 6 February 2018 at 03:47, Guido van Rossum wrote: > If there's going to be an API for it, it should be in the class, not > something that mutates the class afterwards. Something I realised after posting the __class__ setting idea is that you can actually use a comparable

[Python-Dev] libxml2 installation/binding issue

2018-02-05 Thread Priest, Matt
Hello, I am not sure if this is the correct place to post an issue/question like this, but here goes... I've successfully (?) installed Python 3.6.4 and libxml2, with the ultimate goal of installing GTK+ 3.22.0. However, I'm running into this error: python3 Python 3.6.4 (default, Feb 5

Re: [Python-Dev] libxml2 installation/binding issue

2018-02-05 Thread Ethan Smith
This list is for the discussion of development *of* Python. For discussion of development *with* Python, you want python-list. On Mon, Feb 5, 2018 at 2:41 PM, Priest, Matt wrote: > Hello, > > > > I am not sure if this is the correct place to post an issue/question like >

Re: [Python-Dev] Dataclasses and correct hashability

2018-02-05 Thread Guido van Rossum
I'm sorry, but a solution that requires __class__ assignment is way too fragile for my taste. On Mon, Feb 5, 2018 at 6:28 AM, Nick Coghlan wrote: > On 5 February 2018 at 15:49, Guido van Rossum wrote: > > My point is that once you have one of those

Re: [Python-Dev] Dataclasses and correct hashability

2018-02-05 Thread Paul G
I don't think it matters so much whether you are stacking two decorators or a single decorator, but would an @add_unsafe_hash decorator be useful for anything *except* data classes? If not, then there's no point in having a *second* decorator that can *only* modify the first one - particularly