[issue21101] Extend the PyDict C API to handle cases where the hash value is known

2014-05-03 Thread Raymond Hettinger
Changes by Raymond Hettinger : -- resolution: -> fixed status: open -> closed ___ Python tracker ___ ___ Python-bugs-list mailing lis

[issue21101] Extend the PyDict C API to handle cases where the hash value is known

2014-05-03 Thread Roundup Robot
Roundup Robot added the comment: New changeset 592a57682ced by Raymond Hettinger in branch 'default': Issue #21101: Eliminate double hashing in the C code for collections.Counter(). http://hg.python.org/cpython/rev/592a57682ced -- ___ Python tracker

[issue21101] Extend the PyDict C API to handle cases where the hash value is known

2014-05-03 Thread Roundup Robot
Roundup Robot added the comment: New changeset 39f475aa0163 by Raymond Hettinger in branch 'default': Issue 21101: Internal API for dict getitem and setitem where the hash value is known. http://hg.python.org/cpython/rev/39f475aa0163 -- nosy: +python-dev __

[issue21101] Extend the PyDict C API to handle cases where the hash value is known

2014-04-16 Thread Antoine Pitrou
Antoine Pitrou added the comment: I think we can start with making them private. Do you know of any third-party code bases which may be interested in the speedup? -- ___ Python tracker

[issue21101] Extend the PyDict C API to handle cases where the hash value is known

2014-04-16 Thread Raymond Hettinger
Raymond Hettinger added the comment: Antoine, do you support adding these as part of the public API? If not, I can make them private. I think the functions are broadly useful, but no one has ever asked for this functionality either. -- ___ Python

[issue21101] Extend the PyDict C API to handle cases where the hash value is known

2014-04-04 Thread Terry J. Reedy
Terry J. Reedy added the comment: Raymond identified a need and a possible solution. The important part of my post was suggesting another possible solution. Please focus on that. -- ___ Python tracker

[issue21101] Extend the PyDict C API to handle cases where the hash value is known

2014-04-04 Thread R. David Murray
R. David Murray added the comment: Antoine, being polite never hurts. Terry is a valuable member of the community and sure, he sometimes makes mistakes (or trusts the docs too much?). So do the the rest of us. -- nosy: +r.david.murray ___ Python t

[issue21101] Extend the PyDict C API to handle cases where the hash value is known

2014-04-04 Thread Antoine Pitrou
Antoine Pitrou added the comment: > PS: Try being a bit more polite. You could definitely do some research before posting erroneous statements (this one isn't difficult to check, as Alex showed). Especially when the other posters (Alex and Raymond) are a lot more competent than you on the top

[issue21101] Extend the PyDict C API to handle cases where the hash value is known

2014-04-04 Thread Terry J. Reedy
Terry J. Reedy added the comment: "What the hell I am talking about" is what the doc says. 'd[key]' is written just once and "is evaluated just once". https://docs.python.org/3/reference/simple_stmts.html#augmented-assignment-statements PS: Try being a bit more polite. --

[issue21101] Extend the PyDict C API to handle cases where the hash value is known

2014-04-04 Thread Antoine Pitrou
Antoine Pitrou added the comment: > Of course, "d[key] += 1" already solves the double lookup issue at the > Python level. What the hell are you talking about? -- ___ Python tracker ___

[issue21101] Extend the PyDict C API to handle cases where the hash value is known

2014-04-04 Thread Alex Gaynor
Alex Gaynor added the comment: d[key] += 1 still does two dict lookups, and invokes the hash function twice: >>> class X(object): ... def __hash__(self): ... print "hashed" ... return 0 ... def __eq__(self, other): ... return True ... >>> d = {X(): 0} hashed >>> d[X()] hashed 0 >

[issue21101] Extend the PyDict C API to handle cases where the hash value is known

2014-04-04 Thread Terry J. Reedy
Terry J. Reedy added the comment: While the question is reasonable, I agree with Raymond's answer. As a python programmer, I would not like to see d.setitem_known_hash(key, hash, d.getitem_known_hash(key, hash) + 1) Of course, "d[key] += 1" already solves the double lookup issue at the Pytho

[issue21101] Extend the PyDict C API to handle cases where the hash value is known

2014-03-31 Thread Josh Rosenberg
Changes by Josh Rosenberg : -- nosy: +josh.rosenberg ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://ma

[issue21101] Extend the PyDict C API to handle cases where the hash value is known

2014-03-31 Thread Arfrever Frehtes Taifersar Arahesis
Changes by Arfrever Frehtes Taifersar Arahesis : -- nosy: +Arfrever ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscri

[issue21101] Extend the PyDict C API to handle cases where the hash value is known

2014-03-30 Thread Raymond Hettinger
Raymond Hettinger added the comment: > Would it be reasonable to develop a Python API for this? I suspect that in pure Python, the overhead would exceed the benefit. Current code: d[key] = d[key] + 1 Effort to save a double hash: h = hash(key) c = d.getitem_known_hash(key, hash)

[issue21101] Extend the PyDict C API to handle cases where the hash value is known

2014-03-30 Thread Raymond Hettinger
Changes by Raymond Hettinger : -- title: Extend the PyDict C API to handle cases where the hash value in known -> Extend the PyDict C API to handle cases where the hash value is known ___ Python tracker __