[issue27870] Left shift of zero allocates memory

2016-12-05 Thread Mark Dickinson
Mark Dickinson added the comment: Gah. Sorry about that. Thanks for the refleak fix, Benjamin. -- ___ Python tracker ___ ___ Python-bu

[issue27870] Left shift of zero allocates memory

2016-12-03 Thread Roundup Robot
Roundup Robot added the comment: New changeset 2b190bfd9ab4 by Benjamin Peterson in branch '2.7': fix refleak in the shift-by-zero case (#27870) https://hg.python.org/cpython/rev/2b190bfd9ab4 -- ___ Python tracker

[issue27870] Left shift of zero allocates memory

2016-08-29 Thread Mark Dickinson
Mark Dickinson added the comment: Fixed for 2.7 and 3.6. Closing. -- resolution: -> fixed stage: commit review -> resolved status: open -> closed ___ Python tracker ___ ___

[issue27870] Left shift of zero allocates memory

2016-08-29 Thread Roundup Robot
Roundup Robot added the comment: New changeset 58ea646ef657 by Mark Dickinson in branch '2.7': Issue #27870: A left shift of zero by a large integer no longer attempts to allocate large amounts of memory. https://hg.python.org/cpython/rev/58ea646ef657 -- ___

[issue27870] Left shift of zero allocates memory

2016-08-29 Thread Roundup Robot
Roundup Robot added the comment: New changeset 09fa42818cf8 by Mark Dickinson in branch 'default': Issue #27870: A left shift of zero by a large integer no longer attempts to allocate large amounts of memory. https://hg.python.org/cpython/rev/09fa42818cf8 -- nosy: +python-dev _

[issue27870] Left shift of zero allocates memory

2016-08-29 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: LGTM. -- stage: -> commit review ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubs

[issue27870] Left shift of zero allocates memory

2016-08-29 Thread Mark Dickinson
Mark Dickinson added the comment: Updated patch, breaking out the implementation-specific tests into their own method. (Thanks, Serhiy!) -- Added file: https://bugs.python.org/file44256/lshift_zero_v2.patch ___ Python tracker

[issue27870] Left shift of zero allocates memory

2016-08-29 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- nosy: +serhiy.storchaka ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https

[issue27870] Left shift of zero allocates memory

2016-08-29 Thread Mark Dickinson
Mark Dickinson added the comment: Here's a patch against 3.6. I think this probably shouldn't be changed for 3.5, but it may be worth backporting the fix to 2.7. -- keywords: +patch Added file: https://bugs.python.org/file44255/lshift_zero.patch ___

[issue27870] Left shift of zero allocates memory

2016-08-29 Thread Mark Dickinson
Mark Dickinson added the comment: Also applies to 3.x. Working on a fix. -- assignee: -> mark.dickinson versions: +Python 3.5, Python 3.6 ___ Python tracker ___ ___

[issue27870] Left shift of zero allocates memory

2016-08-26 Thread Raymond Hettinger
Changes by Raymond Hettinger : -- nosy: +skrah ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.py

[issue27870] Left shift of zero allocates memory

2016-08-26 Thread R. David Murray
R. David Murray added the comment: Oh, my apologies. I was not reading your message with enough attention, you are only talking about the zero case. A check for zero would not be crazy, and I think there are enough operations involved in left shift that the performance impact would not be me

[issue27870] Left shift of zero allocates memory

2016-08-26 Thread Alex Groce
Alex Groce added the comment: I mean a Python long. GMP mpz (via gmpy2) is supposed to be "drop-in" replacement, but it's choice to handle 0 << N even if N is too large to allocate (since you get back a 1-bit number, 0) seems reasonable, if not required for correct behavior. If this is by de

[issue27870] Left shift of zero allocates memory

2016-08-26 Thread R. David Murray
R. David Murray added the comment: Wait, when you talk about 'long', are you using that in the C sense? Because python long integers are size-limited only by the amount of memory. -- ___ Python tracker _

[issue27870] Left shift of zero allocates memory

2016-08-26 Thread R. David Murray
R. David Murray added the comment: If it raises a MemoryError, then it is working as designed. Returning 0 would be the wrong answer, so I don't understand why GMP would do that. -- ___ Python tracker __

[issue27870] Left shift of zero allocates memory

2016-08-26 Thread Alex Groce
Alex Groce added the comment: Allocates, then fails to perform the operation (with MemoryError). Neither a crash nor resource allocation, precisely, just fails to carry out operation GMP integers can do under the same circumstances. -- ___ Python t

[issue27870] Left shift of zero allocates memory

2016-08-26 Thread R. David Murray
R. David Murray added the comment: Are you saying that Python aborts, or that it raises a MemoryError? -- nosy: +r.david.murray ___ Python tracker ___ __

[issue27870] Left shift of zero allocates memory

2016-08-26 Thread Alex Groce
Alex Groce added the comment: AND, right shift >> does not allocate memory, so there is a lack of symmetry that indicates the optimization might be desired. see https://github.com/agroce/tstl/tree/master/examples/gmpy2/leftshiftalloc.py vs. https://github.com/agroce/tstl/tree/master/examples/

[issue27870] Left shift of zero allocates memory

2016-08-26 Thread Alex Groce
Alex Groce added the comment: (to clarify: 0 << N allocates memory (which can fail, raising MemoryError) based on N. GMP simply returns 0 for any N. -- ___ Python tracker __

[issue27870] Left shift of zero allocates memory

2016-08-26 Thread Alex Groce
New submission from Alex Groce: Using a random testing system to compare Python long behavior to GMP (via gmpy2), I notice that in a low-memory situation (created by allocating many large integers in both Python and GMP), a left-shift of 0 by large number of bytes: - returns 0 via gmpy2 - cau