[issue21424] Simplify and speed-up heaqp.nlargest()

2014-05-03 Thread Raymond Hettinger
New submission from Raymond Hettinger: Consolidate the logic for nlargest() into a single function. Remove both the C and pure Python base underlying code. With all the logic in a single function, it only becomes necessary to create, store, and compare the data tuples when a need item is add

[issue19414] iter(ordered_dict) yields keys not in dict in some circumstances

2014-05-03 Thread Raymond Hettinger
Raymond Hettinger added the comment: To address Armin's concern, I'm triggering an early failure by setting the link fields to None. That will help prevent accidental reliance on non-guaranteed behaviors. -- resolution: -> fixed status: open -> closed ___

[issue19414] iter(ordered_dict) yields keys not in dict in some circumstances

2014-05-03 Thread Roundup Robot
Roundup Robot added the comment: New changeset a3c345ba3563 by Raymond Hettinger in branch 'default': Issue #19414: Have the OrderedDict mark deleted links as unusable. http://hg.python.org/cpython/rev/a3c345ba3563 -- nosy: +python-dev ___ Python trac

[issue18604] Consolidate gui available checks in test.support

2014-05-03 Thread Ned Deily
Ned Deily added the comment: For some reason, the newly-added Tk instantiation check causes the OS X Cocoa Tk to segfault when tests are run under regrtest -jn option, which causes each test to be run under a separate subprocess called from a separate thread. Somewhat surprisingly, the segfau

[issue18604] Consolidate gui available checks in test.support

2014-05-03 Thread Roundup Robot
Roundup Robot added the comment: New changeset 7ecb6e4b1077 by Ned Deily in branch '3.4': Issue #18604: Skip the Tk instantiation test on OS X because it can http://hg.python.org/cpython/rev/7ecb6e4b1077 New changeset 7f6d9990a9b1 by Ned Deily in branch 'default': Issue #18604: merge from 3.4 ht

[issue21414] Add an intersperse function to itertools

2014-05-03 Thread Raymond Hettinger
Raymond Hettinger added the comment: I've looked into this a bit more. Even in Haskell, it seems that use case is for str.join() which we already have. I don't see intersperse() in any other functional languages. That suggests that its use cases aren't sufficiently common to warrant adding

[issue21421] ABCs for MappingViews should declare __slots__ so subclasses aren't forced to have __dict__/__weakref__

2014-05-03 Thread Raymond Hettinger
Raymond Hettinger added the comment: I've applied the __slots__ patch. Thank you for submitting it. Am leaving the rest of the ABCs code as-is. The current form may be a bit wordy but it is clean, fast, and easy to trace through a debugger. The expanded forms were chosen for a reason.

[issue21421] ABCs for MappingViews should declare __slots__ so subclasses aren't forced to have __dict__/__weakref__

2014-05-03 Thread Roundup Robot
Roundup Robot added the comment: New changeset 2c6a231e2c1e by Raymond Hettinger in branch 'default': Issue #21421: Add __slots__ to the MappingViews ABCs. http://hg.python.org/cpython/rev/2c6a231e2c1e -- nosy: +python-dev ___ Python tracker

[issue20642] Enhance deepcopy-ing for tuples

2014-05-03 Thread Raymond Hettinger
Raymond Hettinger added the comment: This was a nice patch. Thanks. -- nosy: +rhettinger ___ Python tracker ___ ___ Python-bugs-list m

[issue20642] Enhance deepcopy-ing for tuples

2014-05-03 Thread Roundup Robot
Roundup Robot added the comment: New changeset 0df3004581fe by Benjamin Peterson in branch 'default': improve idioms (closes #20642) http://hg.python.org/cpython/rev/0df3004581fe -- nosy: +python-dev resolution: -> fixed stage: -> resolved status: open -> closed __

[issue21357] Increase filecmp test coverage from 63% to 76%

2014-05-03 Thread Roundup Robot
Roundup Robot added the comment: New changeset 57dacba9febf by Benjamin Peterson in branch '3.4': improve test coverage of filecmp (closes #21357) http://hg.python.org/cpython/rev/57dacba9febf New changeset c597654a7fd8 by Benjamin Peterson in branch 'default': merge 3.4 (#21357) http://hg.pytho

[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

[issue21121] -Werror=declaration-after-statement is added even for extension modules through setup.py

2014-05-03 Thread Larry Hastings
Larry Hastings added the comment: If you guys want this in 3.4.1, please get it checked in in the next, oh, eight hours. -- ___ Python tracker ___ __

[issue21423] concurrent.futures.ThreadPoolExecutor should accept an initializer argument

2014-05-03 Thread Andreas van Cranenburgh
New submission from Andreas van Cranenburgh: It would be useful if concurrent.futures.ThreadPoolExecutor took an initializer argument, like multiprocessing.Pool. This is useful for example to load a large dataset once upon initialization of each worker process, without have to pass the dataset

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

[issue21233] Add *Calloc functions to CPython memory allocation API

2014-05-03 Thread Stefan Krah
Stefan Krah added the comment: STINNER Victor wrote: > PyObject_Malloc(100) asks to allocate one object of 100 bytes. Okay, then let's please call it: _PyObject_Calloc(void *ctx, size_t nobjs, size_t objsize) _PyObject_Alloc(int use_calloc, void *ctx, size_t nobjs, size_t objsize) --

[issue17338] Add length_hint parameter to list, dict, set constructors to allow efficient presizing

2014-05-03 Thread Raymond Hettinger
Raymond Hettinger added the comment: Based on all the negative comments, I'm closing this one. It adds too much complication in return for dubious value. -- resolution: -> rejected status: open -> closed ___ Python tracker

[issue21121] -Werror=declaration-after-statement is added even for extension modules through setup.py

2014-05-03 Thread Ned Deily
Ned Deily added the comment: I agree: issue21121-3.diff is a much better approach. -- ___ Python tracker ___ ___ Python-bugs-list mail

[issue21233] Add *Calloc functions to CPython memory allocation API

2014-05-03 Thread STINNER Victor
STINNER Victor added the comment: >"allocate nbytes elements of size 1" PyObject_Malloc(100) asks to allocate one object of 100 bytes. For PyMem_Malloc() and PyMem_RawMalloc(), it's more difficult to guess, but IMO it's sane to bet that a single memory block of size bytes is requested. I c

[issue21233] Add *Calloc functions to CPython memory allocation API

2014-05-03 Thread Stefan Krah
Stefan Krah added the comment: > > 5) If WITH_VALGRIND is defined, nbytes is uninitialized in > _PyObject_Alloc(). > > Did you see my second commit? It's nlt already fixed? I don't think so, I have revision 5d076506b3f5 here. -- ___ Python tracker

[issue21233] Add *Calloc functions to CPython memory allocation API

2014-05-03 Thread STINNER Victor
STINNER Victor added the comment: > 5) If WITH_VALGRIND is defined, nbytes is uninitialized in _PyObject_Alloc(). Did you see my second commit? It's nlt already fixed? -- ___ Python tracker ___

[issue21233] Add *Calloc functions to CPython memory allocation API

2014-05-03 Thread STINNER Victor
STINNER Victor added the comment: > 6) We need some kind of prominent documentation that existing >programs need to be changed: My final commit includes an addition to What's New in Python 3.5 doc, including a notice in the porting section. It is not enough? Even if the API is public, the P

[issue21375] Fix and test overflow behavior in the C version of heapq

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

[issue21422] int << 0: return the number unmodified

2014-05-03 Thread STINNER Victor
STINNER Victor added the comment: > I would think that in real-world code, this branch will almost never be taken. The common case will pay a price (albiet a small one) for almost zero benefit. I think that x << 0 is common even if it's not written like that (it's more for i in range(8): ... x

[issue21375] Fix and test overflow behavior in the C version of heapq

2014-05-03 Thread Roundup Robot
Roundup Robot added the comment: New changeset b768d41dec0a by Raymond Hettinger in branch '2.7': Issue 21375: Fix possible Py_ssizet overflow in heapq. http://hg.python.org/cpython/rev/b768d41dec0a -- ___ Python tracker

[issue21375] Fix and test overflow behavior in the C version of heapq

2014-05-03 Thread Roundup Robot
Roundup Robot added the comment: New changeset 725cb631699a by Raymond Hettinger in branch '3.4': Issue 21375: Fix possible Py_ssizet overflow in heapq. http://hg.python.org/cpython/rev/725cb631699a -- nosy: +python-dev ___ Python tracker

[issue21422] int << 0: return the number unmodified

2014-05-03 Thread Raymond Hettinger
Raymond Hettinger added the comment: Every branch has a cost (in particular, it tends to contaminate global branch prediction tables and blow other code out of the L1 code cache). The cost isn't big, but branches shouldn't be added unless we know there is a real benefit. I would think that i

[issue20215] Python2.7 socketserver can not listen IPv6 address

2014-05-03 Thread Andreas Røsdal
Andreas Røsdal added the comment: Here's a patch which implements support in SocketServer to set IPv6 socket address family to AF_INET6 automatically if the TCPServer is specified to listen to an IPv6 address. This means that users of the TCPServer class will get the correct address family aut

[issue21233] Add *Calloc functions to CPython memory allocation API

2014-05-03 Thread Nathaniel Smith
Nathaniel Smith added the comment: A simple solution would be to change the name of the struct, so that non-updated libraries will get a compile error instead of a runtime crash. -- ___ Python tracker

[issue21233] Add *Calloc functions to CPython memory allocation API

2014-05-03 Thread Stefan Krah
Stefan Krah added the comment: Another thing: 6) We need some kind of prominent documentation that existing programs need to be changed: Python 3.5.0a0 (default:62438d1b11c7+, May 3 2014, 23:35:03) [GCC 4.8.2] on linux Type "help", "copyright", "credits" or "license" for more information.

[issue20866] segfailt with os.popen and SIGPIPE

2014-05-03 Thread Charles-François Natali
Charles-François Natali added the comment: It's segfaulting inside fwrite(), so apart from completely rewriting the IO layer in 2.x, I don't see. -- ___ Python tracker ___ __

[issue21233] Add *Calloc functions to CPython memory allocation API

2014-05-03 Thread Stefan Krah
Stefan Krah added the comment: I forgot one thing: 5) If WITH_VALGRIND is defined, nbytes is uninitialized in _PyObject_Alloc(). -- ___ Python tracker ___ __

[issue20866] segfailt with os.popen and SIGPIPE

2014-05-03 Thread Terry J. Reedy
Terry J. Reedy added the comment: I was thinking the same thing. This appears to be one of the 2.x bugs that have been fixed in 3.x but not 2.x because backporting the fix might break working code. If there another sensible fix that would be acceptable in 2.x? -- _

[issue20866] segfailt with os.popen and SIGPIPE

2014-05-03 Thread Charles-François Natali
Charles-François Natali added the comment: > I can reproduce the crash. It occurs at the line "fd.write(data)". It looks > like the crash occurs in the C function fwrite() which doesn't handle EPIPE / > SIGPIPE correctly. Wouldn't be the first time. Note that in Python 3, we don't fopen/fwrit

[issue21233] Add *Calloc functions to CPython memory allocation API

2014-05-03 Thread Stefan Krah
Stefan Krah added the comment: I did a post-commit review. A couple of things: 1) I think Victor and I have a different view of the calloc() parameters. calloc(size_t nmemb, size_t size) If a memory region of bytes is allocated, IMO 'nbytes' should be in the place of 'nmemb' and

[issue18564] Integer overflow in socketmodule

2014-05-03 Thread Michele Orrù
Michele Orrù added the comment: Interestingly, implements a function for parsing bluetooth addresses, but it's completely broken. It would be much much more elegant to use str2ba() in our source code though. I am think

[issue18564] Integer overflow in socketmodule

2014-05-03 Thread Michele Orrù
Changes by Michele Orrù : Added file: http://bugs.python.org/file35146/issue18564.3.patch ___ Python tracker ___ ___ Python-bugs-list mailing

[issue21352] improve documentation indexing

2014-05-03 Thread Tshepang Lekhonkhobe
Changes by Tshepang Lekhonkhobe : -- nosy: +tshepang ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://ma

[issue14019] Unify tests for str.format and string.Formatter

2014-05-03 Thread Brett Cannon
Changes by Brett Cannon : -- assignee: -> brett.cannon nosy: +brett.cannon ___ Python tracker ___ ___ Python-bugs-list mailing list U

[issue20866] segfailt with os.popen and SIGPIPE

2014-05-03 Thread STINNER Victor
STINNER Victor added the comment: I can reproduce the crash. It occurs at the line "fd.write(data)". It looks like the crash occurs in the C function fwrite() which doesn't handle EPIPE / SIGPIPE correctly. Top of the gdb traceback: #0 0x0033d0a8968b in __mempcpy_sse2 () from /lib64/libc

[issue21420] Optimize 2 ** n: implement it as 1 << n

2014-05-03 Thread STINNER Victor
STINNER Victor added the comment: pow2_specialized.patch: here is a different approach, a little bit faster. I wrote a dedicated long_pow2() function which computes 2**k. Arguments in favor of pow2_specialized.patch instead of pow2.patch: - it's a little bit faster - don't touch long_lshift(),

[issue21422] int << 0: return the number unmodified

2014-05-03 Thread STINNER Victor
New submission from STINNER Victor: I propose to add a micro-optimization for int << 0: return the number unmodified. See attached patch. -- files: long_lshift0.patch keywords: patch messages: 217822 nosy: haypo, mark.dickinson, serhiy.storchaka priority: normal severity: normal status

[issue20544] Use specific asserts in operator tests

2014-05-03 Thread Andrew Svetlov
Andrew Svetlov added the comment: Ok. I agree with Teddy but Raymond's arguments make a value also. Thus we need to make any decision and close the issue (and bunch of similar issues). On Sat, May 3, 2014 at 8:38 AM, Terry J. Reedy wrote: > > Terry J. Reedy added the comment: > > The generic er

[issue21420] Optimize 2 ** n: implement it as 1 << n

2014-05-03 Thread Stefan Behnel
Stefan Behnel added the comment: LGTM, can't see a case where this might go wrong (errors and type checks are handled before the added code). It also seems a sufficiently common case to optimise it internally. The 2**n spelling is easier to read and to get right than the shifting, so it's good

[issue21415] Python __new__ method doc typo (it's a class and not a static method)

2014-05-03 Thread Jurko Gospodnetić
Jurko Gospodnetić added the comment: Thanks for the detailed response! :-( I should have tested more before reporting the issue. Sorry for the noise. :-( I saw the 'cls' argument and assumed it was a class method. Having to explicitly specify cls did not seem to be in contradiction with this si