[issue43475] Worst-case behaviour of hash collision with float NaN

2021-11-24 Thread Christoph Groth


Christoph Groth  added the comment:

> What concrete action would you propose that the Python core devs take at this 
> point?

Nothing for now.

I stumbled across this issue through 
https://gitlab.kwant-project.org/kwant/tinyarray/-/issues/20 and had the 
impression that the aspect that I raised (that, for example, hash values of 
immutable built-in objects now no longer survive pickling) was not examined in 
this otherwise in-depth discussion.  So I added it for reference.

If problems come up that are caused by this change, I would consider reverting 
it a possible solution.

> The result of the change linked to this PR is that the hash now also reflects 
> that containment depends on object identity, not just object value.

This is a nice way to phrase it.  Thanks for the link to the entertaining talk. 
:-)

--

___
Python tracker 
<https://bugs.python.org/issue43475>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43475] Worst-case behaviour of hash collision with float NaN

2021-11-24 Thread Christoph Groth


Christoph Groth  added the comment:

Hello.  I would like to point out a possible problem that this change to 
CPython has introduced.

This change looks innocent, but it breaks the unwritten rule that the hash 
value of a number (or actually any built-in immutable type!) in Python depends 
only on its value.

Thus, before this change, it was possible to convert a tuple of floats into a 
numpy array and back into a tuple, and the hash values of both tuples would be 
equal.  This is no longer the case.

Or, more generally, any hashable tuple could be pickled and unpickled, without 
changing its hash value.  I could well imagine that this breaks real code in 
subtle ways.

Likewise, it is now no longer possible to provide a library of sequences of 
numbers that always hashes like built-in tuples.  (As "tinyarray", of which I 
am the author, did.)

--
nosy: +cwg

___
Python tracker 
<https://bugs.python.org/issue43475>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15767] add ModuleNotFoundError

2018-02-27 Thread Christoph Groth

Christoph Groth <christ...@grothesque.org> added the comment:

Unfortunately I do not feel competent enough to submit a documentation patch 
because I still do not understand why ModuleNotFoundError was added.

I don't want to bother you further with this.  Thank you all for your prompt 
replies.  If you agree with me that there is indeed an issue, please open it 
yourself.

--

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue15767>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15767] add ModuleNotFoundError

2018-02-27 Thread Christoph Groth

Christoph Groth <christ...@grothesque.org> added the comment:

Thank you, Chris, for your reply.  If this is indeed the main use case of 
ModuleNotFoundError, I respectfully suggest to document it better.  The way 
things are now, Python users who switch to 3.6 encounter this new exception 
during their work with the interpreter and invariably wonder "Should I change 
anything in my code because of this?  If not, why was it introduced?".  In my 
opinion the current documentation does not answer these questions well.  Note 
that this is not about some deeply buried detail.  Every Python programmer is 
bound to encounter this.

That said, I cannot imagine many cases where user code would like to fall back 
to html.parser only if fancy_parser is not installed but not if an older 
version of fancy_parser is installed (or maybe it's an entirely *different* 
fancy_parser?).  And in the rare cases where that is desired, it was already 
perfectly idiomatic to do so:

try:
import fancy_parser
except ImportError:
from html.parser import HTMLParser
else:
from fancy_parser import NewParser as HTMLParser

--

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue15767>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15767] add ModuleNotFoundError

2018-02-26 Thread Christoph Groth

Christoph Groth <christ...@grothesque.org> added the comment:

In the above, please replace "understand the decision" by "understand the 
usefulness of it".

In the above discussion, as an alternative to a new exception, it was proposed 
to add an attribute to ImportError ('reason'), but then people seemed to agree 
that this is quite useless outside of importlib (msg192261).  But then I don't 
understand why the original idea of the exception was revived.

--

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue15767>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15767] add ModuleNotFoundError

2018-02-26 Thread Christoph Groth

Christoph Groth <christ...@grothesque.org> added the comment:

My curiosity was piqued when I saw ModuleNotFoundError, so I decided to look it 
up.  This led me to this page and I read the complete discussion.  I still did 
not understand the decision, so I allowed myself to ask,  also because I 
believe that when new features are introduced it should be clear what they are 
good for.  That's all.

--

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue15767>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15767] add ModuleNotFoundError

2018-02-26 Thread Christoph Groth

Christoph Groth <christ...@grothesque.org> added the comment:

> Read Eric's message before mine.

Of course I read it, I wouldn't have asked otherwise.  Eric mentions an older 
message ("see msg182332") that *predates* your judgment that "outside importlib 
there shouldn't be a need to distinguish between the cases".  Otherwise Eric 
says that he finds "the exception to be very useful", but frankly, I don't see 
why (outside of importlib or backports of it).  What changed since msg192263?

--

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue15767>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15767] add ModuleNotFoundError

2018-02-26 Thread Christoph Groth

Christoph Groth <christ...@grothesque.org> added the comment:

I'm trying to understand why ModuleNotFoundError was added to 3.6.  The "what's 
new" entry links to this page.

Looking at the discussion, Guido said in 2013: "Right.  Outside importlib there 
shouldn't be a need to distinguish between the cases (especially given that the 
exception works differently than its name suggests).".  Then, three years 
later, he supports the inclusion of the patch, without that any new arguments 
had been given.

Could someone explain (or link to) what happened inbetween?

--
nosy: +cwg

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue15767>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com