[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

[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

[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 r

[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 exc

[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 attribu

[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 bec

[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 t

[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

dict: retrieve the original key by key

2011-05-15 Thread Christoph Groth
Dear python experts, I use a huge python dictionary where the values are lists of that dictionary's keys (yes, a graph). Each key is thus referenced several times. As the keys are rather large objects, I would like to save memory by re-using key objects wherever possible, instead of having

Re: dict: retrieve the original key by key

2011-05-15 Thread Christoph Groth
Chris Rebert c...@rebertia.com writes: On Sun, May 15, 2011 at 1:28 AM, Christoph Groth c...@falma.de wrote: I use a huge python dictionary where the values are lists of that dictionary's keys (yes, a graph).  Each key is thus referenced several times. As the keys are rather large objects

Re: dict: retrieve the original key by key

2011-05-15 Thread Christoph Groth
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info writes: On Sun, 15 May 2011 11:11:41 +0200, Christoph Groth wrote: I would like to avoid having _multiple_ objects which are equal (a == b) but not the same (a is not b). This would save a lot of memory. Based on the idea of interning

constructing an object from another instance of the same class

2010-06-18 Thread Christoph Groth
Dear all, sometimes it is handy to have a function which can take as argument anything which can be converted into something, e.g. def foo(arg): arg = float(arg) # ... I would like to mimic this behavior of float for a user-defined type, e.g. def bar(arg): arg = My_type(arg) #

Re: constructing an object from another instance of the same class

2010-06-18 Thread Christoph Groth
Bruno Desthuilliers bruno.42.desthuilli...@websiteburo.invalid writes: It seems to me that in this way I might get problems when I pass an instance of Derived_from_my_type to bar, as it will become an instance of My_type. The instance you pass to bar won't become anything else. You create a

Re: constructing an object from another instance of the same class

2010-06-18 Thread Christoph Groth
Bruno Desthuilliers bruno.42.desthuilli...@websiteburo.invalid writes: Anyway: the simplest solution here is to replace the call to your Base class with a call to a factory function. I'd probably go for something like (QD untested code and other usual warnings) : (...) Yeah, that will do

Re: constructing an object from another instance of the same class

2010-06-18 Thread Christoph Groth
Steven D'Aprano st...@remove-this-cybersource.com.au writes: On Fri, 18 Jun 2010 16:30:00 +0200, Christoph Groth wrote: If other is of type Base already, just pass it on. Otherwise, construct an instance of Base from