Re: [Python-Dev] cpython: Use cached builtins.

2013-10-03 Thread Georg Brandl
Am 02.10.2013 21:58, schrieb Victor Stinner: I don't remember where, but I remember that I also saw things like str=str, len=len, So you keep the same name, but you use fast local lookups instead of slow builtin lookups. In this case they aren't even fast local lookups but (slightly)

Re: [Python-Dev] cpython: Use cached builtins.

2013-10-03 Thread Nick Coghlan
On 3 Oct 2013 06:00, Victor Stinner victor.stin...@gmail.com wrote: I don't remember where, but I remember that I also saw things like str=str, len=len, So you keep the same name, but you use fast local lookups instead of slow builtin lookups. functools uses the local binding trick in

Re: [Python-Dev] cpython: Use cached builtins.

2013-10-03 Thread Michael Foord
On 3 Oct 2013, at 12:05, Nick Coghlan ncogh...@gmail.com wrote: On 3 Oct 2013 06:00, Victor Stinner victor.stin...@gmail.com wrote: I don't remember where, but I remember that I also saw things like str=str, len=len, So you keep the same name, but you use fast local lookups

[Python-Dev] summing integer and class

2013-10-03 Thread Igor Vasilyev
Hi. Example test.py: class A(): def __add__(self, var): print(I'm in A class) return 5 a = A() a+1 1+a Execution: python test.py I'm in A class Traceback (most recent call last): File ../../test.py, line 7, in module 1+a TypeError: unsupported operand type(s) for +:

[Python-Dev] summing integer and class

2013-10-03 Thread Игорь Васильев
Hi. Example test.py: class A():     def __add__(self, var):     print(I'm in A class)     return 5 a = A() a+1 1+a Execution: python test.py I'm in A class Traceback (most recent call last):   File ../../test.py, line 7, in module     1+a TypeError: unsupported operand type(s) for +:

[Python-Dev] PEP 454: Add a new tracemalloc module (final version)

2013-10-03 Thread Victor Stinner
Hi, I worked on the implementation of the tracemalloc module and its PEP 454. I consider that this third version of the PEP is ready for a final review. What should be done to finish the PEP? HTML version of the PEP 454: http://www.python.org/dev/peps/pep-0454/ Full documentation of the

Re: [Python-Dev] summing integer and class

2013-10-03 Thread Chris Angelico
On Thu, Oct 3, 2013 at 11:09 PM, Игорь Васильев vasilyev_i...@inbox.ru wrote: When we adding class to integer we have both slotv and slotw. x = slotv(v, w); - returns Py_NotImplemented. But in this case we should execute x = slotw(v, w); and function should be completed in the same way as when

Re: [Python-Dev] summing integer and class

2013-10-03 Thread Xavier Morel
On 2013-10-03, at 15:45 , Igor Vasilyev wrote: Hi. Example test.py: class A(): def __add__(self, var): print(I'm in A class) return 5 a = A() a+1 1+a Execution: python test.py I'm in A class Traceback (most recent call last): File ../../test.py, line 7, in

Re: [Python-Dev] summing integer and class

2013-10-03 Thread Chris Kaynor
This list is for development OF Python, not for development in python. For that reason, I will redirect this to python-list as well. My actual answer is below. On Thu, Oct 3, 2013 at 6:45 AM, Igor Vasilyev igor.vasil...@oracle.com wrote: Hi. Example test.py: class A(): def

[Python-Dev] Make str/bytes hash algorithm pluggable?

2013-10-03 Thread Christian Heimes
Hi, some of you may have seen that I'm working on a PEP for a new hash API and new algorithms for hashing of bytes and str. The PEP has three major aspects. It introduces DJB's SipHash as secure hash algorithm, chances the hash API to process blocks of data instead characters and it adds an API

Re: [Python-Dev] Make str/bytes hash algorithm pluggable?

2013-10-03 Thread Antoine Pitrou
On Thu, 03 Oct 2013 20:42:28 +0200 Christian Heimes christ...@python.org wrote: I haven't actually benchmarked how a faster hash algorithm affects the a real program, though ... Chances are it doesn't. Only a slow enough hash algorithm might have an impact, IMHO. On which level should

Re: [Python-Dev] Make str/bytes hash algorithm pluggable?

2013-10-03 Thread Guido van Rossum
Hm. I would like to stick to the philosophy that Python's hash should be as fast as it possibly can be, and should not be mistaken for a cryptographic hash. The point is to optimize dict lookups, nothing more, given typical (or even atypical) key distribution, not to thwart deliberate attacks. We

Re: [Python-Dev] Make str/bytes hash algorithm pluggable?

2013-10-03 Thread Christian Heimes
Am 03.10.2013 21:05, schrieb Guido van Rossum: Hm. I would like to stick to the philosophy that Python's hash should be as fast as it possibly can be, and should not be mistaken for a cryptographic hash. The point is to optimize dict lookups, nothing more, given typical (or even atypical) key

Re: [Python-Dev] Make str/bytes hash algorithm pluggable?

2013-10-03 Thread Guido van Rossum
On Thu, Oct 3, 2013 at 12:23 PM, Christian Heimes christ...@python.orgwrote: Am 03.10.2013 21:05, schrieb Guido van Rossum: Hm. I would like to stick to the philosophy that Python's hash should be as fast as it possibly can be, and should not be mistaken for a cryptographic hash. The point

[Python-Dev] PEP 456

2013-10-03 Thread Serhiy Storchaka
Just some comments. the first time time with a bit shift of 7 Double time. with a 128bit seed and 64-bit output Inconsistancy with hyphen. There are same issues in other places. bytes_hash provides the tp_hash slot function for unicode. Typo. Should be unicode_hash. len =

Re: [Python-Dev] Make str/bytes hash algorithm pluggable?

2013-10-03 Thread Christian Heimes
Am 03.10.2013 21:45, schrieb Guido van Rossum: But fixing that shouldn't need all the extra stuff you're proposing. I have proposed some of the extra stuff for more flexibility, the rest is for testing and debugging. What's a Python randomization key? Python's hash randomization key, the

Re: [Python-Dev] [Python-checkins] cpython: [issue19151] Fix issue number in Misc/NEWS entry.

2013-10-03 Thread A.M. Kuchling
On Thu, Oct 03, 2013 at 08:48:47PM +0200, eric.snow wrote: -- Issue #19951: Fix docstring and use of _get_suppported_file_loaders() to +- Issue #19151: Fix docstring and use of _get_suppported_file_loaders() to ^^^ likely a typo? --amk

Re: [Python-Dev] Make str/bytes hash algorithm pluggable?

2013-10-03 Thread Victor Stinner
2013/10/3 Christian Heimes christ...@python.org: A hash algorithm can be added and one avaible hash algorithm can be set before Py_Initialize() is called for the first time. Py_Initialize is not the good guard. Try for example python3 -X faulthandler: PyObject_Hash() is called before

Re: [Python-Dev] [Python-checkins] cpython: [issue19151] Fix issue number in Misc/NEWS entry.

2013-10-03 Thread Eric Snow
On Thu, Oct 3, 2013 at 1:57 PM, A.M. Kuchling a...@amk.ca wrote: On Thu, Oct 03, 2013 at 08:48:47PM +0200, eric.snow wrote: -- Issue #19951: Fix docstring and use of _get_suppported_file_loaders() to +- Issue #19151: Fix docstring and use of _get_suppported_file_loaders() to

Re: [Python-Dev] [Python-checkins] cpython: [issue19151] Fix issue number in Misc/NEWS entry.

2013-10-03 Thread Barry Warsaw
On Oct 03, 2013, at 02:08 PM, Eric Snow wrote: On Thu, Oct 3, 2013 at 1:57 PM, A.M. Kuchling a...@amk.ca wrote: On Thu, Oct 03, 2013 at 08:48:47PM +0200, eric.snow wrote: -- Issue #19951: Fix docstring and use of _get_suppported_file_loaders() to +- Issue #19151: Fix docstring and use of

Re: [Python-Dev] [Python-checkins] cpython: [issue19151] Fix issue number in Misc/NEWS entry.

2013-10-03 Thread Eric Snow
On Thu, Oct 3, 2013 at 2:21 PM, Barry Warsaw ba...@python.org wrote: PPProbably not the typppo Andrew was pppointing out. -Bary Ohhh, that typppo. -eric ___ Python-Dev mailing list Python-Dev@python.org

Re: [Python-Dev] Make str/bytes hash algorithm pluggable?

2013-10-03 Thread Guido van Rossum
On Thu, Oct 3, 2013 at 12:55 PM, Christian Heimes christ...@python.orgwrote: Am 03.10.2013 21:45, schrieb Guido van Rossum: But fixing that shouldn't need all the extra stuff you're proposing. I have proposed some of the extra stuff for more flexibility, the rest is for testing and

Re: [Python-Dev] PEP 456

2013-10-03 Thread Christian Heimes
Am 03.10.2013 21:53, schrieb Serhiy Storchaka: the first time time with a bit shift of 7 Double time. thx, fixed with a 128bit seed and 64-bit output Inconsistancy with hyphen. There are same issues in other places. I have unified the use of hyphens, thx! bytes_hash provides the

Re: [Python-Dev] Make str/bytes hash algorithm pluggable?

2013-10-03 Thread Nick Coghlan
On 4 Oct 2013 06:08, Victor Stinner victor.stin...@gmail.com wrote: 2013/10/3 Christian Heimes christ...@python.org: A hash algorithm can be added and one avaible hash algorithm can be set before Py_Initialize() is called for the first time. Py_Initialize is not the good guard. Try for

Re: [Python-Dev] Make str/bytes hash algorithm pluggable?

2013-10-03 Thread Guido van Rossum
On Thu, Oct 3, 2013 at 2:13 PM, Nick Coghlan ncogh...@gmail.com wrote: On 4 Oct 2013 06:08, Victor Stinner victor.stin...@gmail.com wrote: 2013/10/3 Christian Heimes christ...@python.org: A hash algorithm can be added and one avaible hash algorithm can be set before Py_Initialize() is

Re: [Python-Dev] Make str/bytes hash algorithm pluggable?

2013-10-03 Thread Serhiy Storchaka
03.10.13 23:47, Guido van Rossum написав(ла): On Thu, Oct 3, 2013 at 12:55 PM, Christian Heimes christ...@python.org mailto:christ...@python.org wrote: Am 03.10.2013 21:45, schrieb Guido van Rossum: But fixing that shouldn't need all the extra stuff you're proposing. I have

Re: [Python-Dev] summing integer and class

2013-10-03 Thread Greg Ewing
Igor Vasilyev wrote: class A(): def __add__(self, var): print(I'm in A class) return 5 a = A() a+1 1+a Execution: python test.py I'm in A class Traceback (most recent call last): File ../../test.py, line 7, in module 1+a TypeError: unsupported operand type(s) for +:

Re: [Python-Dev] Make str/bytes hash algorithm pluggable?

2013-10-03 Thread Gregory P. Smith
On Thu, Oct 3, 2013 at 11:42 AM, Christian Heimes christ...@python.orgwrote: Hi, some of you may have seen that I'm working on a PEP for a new hash API and new algorithms for hashing of bytes and str. The PEP has three major aspects. It introduces DJB's SipHash as secure hash algorithm,

Re: [Python-Dev] Make str/bytes hash algorithm pluggable?

2013-10-03 Thread Gregory P. Smith
On Thu, Oct 3, 2013 at 12:05 PM, Guido van Rossum gu...@python.org wrote: We already have adopted a feature that plugged most viable attacks on web apps, I think that's enough. Actually... we did not do a very good job on that: http://bugs.python.org/issue14621 The point of allowing

Re: [Python-Dev] Make str/bytes hash algorithm pluggable?

2013-10-03 Thread Gregory P. Smith
On Thu, Oct 3, 2013 at 1:06 PM, Victor Stinner victor.stin...@gmail.comwrote: 2013/10/3 Christian Heimes christ...@python.org: A hash algorithm can be added and one avaible hash algorithm can be set before Py_Initialize() is called for the first time. Py_Initialize is not the good guard.