[issue33073] Add as_integer_ratio() to int() objects

2018-03-15 Thread Tim Peters
Tim Peters added the comment: Thanks, Mark! So if int.as_integer_ratio is added to the core, numpy.int64 won't magically have it too, regardless of whether we do or don't add an implementation to numbers.Rational. As an end user, I'd be surprised if numpy.int64 didn't su

[issue26680] Incorporating float.is_integer into the numeric tower and Decimal

2018-03-15 Thread Tim Peters
Tim Peters added the comment: [Raymond] > The OPs notion of "absurd" behavior implies a rule that > all float methods should be available for ints. That > would suggest the is_integer, hex, fromhex, and > as_integer_ratio would all need to propagate to the > other type

[issue33073] Add as_integer_ratio() to int() objects

2018-03-15 Thread Tim Peters
Tim Peters added the comment: Serhiy, I don't understand. If `numbers.Rational` is in fact a superclass of `numpy.int64`, then the latter will inherit an implementation added to the former. The idea here isn't to add an abstract method to the Rational interface, but a concre

[issue33073] Add as_integer_ratio() to int() objects

2018-03-13 Thread Tim Peters
Tim Peters added the comment: Thanks, Guido! I figured I was missing something :-) It looks like `numbers.Rational` _is_ a "for real" base class of `fractions.Fraction`, though, so I'm in favor of supplying a default implementation of `.as_integer_ratio()` in `numbers.R

[issue33073] Add as_integer_ratio() to int() objects

2018-03-13 Thread Tim Peters
Tim Peters added the comment: Serhiy, we already went down the path of implementing this as a method. Of course `numbers.Rational` could define the method as `return (self.numerator, self.denominator)` for itself and its subclasses. Unless I'm confused, that would "magically&q

[issue33073] Add as_integer_ratio() to int() objects

2018-03-13 Thread Tim Peters
Tim Peters added the comment: > Is this also desired for fractions.Fraction and numbers.Rational? I think so. The idea, e.g., that "it's obvious" for Fraction is no more compelling than that it's even more obvious for ints ;-) Given that it's spreadin

[issue33022] Floating Point Arithmetic Inconsistency (internal off-by-one)

2018-03-07 Thread Tim Peters
Tim Peters added the comment: What did you expect? The precision of Python ints is limited only by the amount of memory you have, but Python floats are IEEE-754 double precision numbers, and have only 53 bits of precision. 2**53 + 1 simply can't be represented exactly as a float

[issue32879] Race condition in multiprocessing Queue

2018-02-19 Thread Tim Peters
Tim Peters added the comment: The docs could be clearer about this: the argument to .put() is _not_ pickled at the time .put() is called. The object is remembered (by reference, not by value), and a feeder thread pickles the value and puts the pickle on the queue when the feeder thread

[issue32846] Deletion of large sets of strings is extra slow

2018-02-16 Thread Tim Peters
Tim Peters added the comment: > Surprisingly, deleting a very large set takes much longer than creating it. Luis, that's not surprising ;-) When you create it, it's mostly the case that there's a vast chunk of raw memory from which many pieces are passed out in address

[issue32767] Mutating a list while iterating: clarify the docs

2018-02-10 Thread Tim Peters
Tim Peters added the comment: Stefan, yup! Thank you. `array.array` and `bytearray` iterators appear to work the same way as `list` iterators here. Terry, the note in the `for` statement docs was written before there _was_ an iterator protocol. For example, here are the 1.5.1 docs: https

[issue32783] ln(2) isn't accurate in _math.c in cpython

2018-02-06 Thread Tim Peters
Tim Peters added the comment: As I mentioned on StackOverflow, the literal in question appears to have been crafted to convert to the best possible 53-bit binary approximation to log(2) regardless of whether a compiler converts it to double precision (53 bits of precision) or to "d

[issue32767] Mutating a list while iterating: clarify the docs

2018-02-05 Thread Tim Peters
Tim Peters added the comment: Some other points to consider: I don't think this belongs in the `for` statement docs at all. Instead they should merely _note_ that what happens if a sequence being iterated over is mutated is up to the sequence iterator. Then, e.g., the `list` docs s

[issue32767] Mutating a list while iterating: clarify the docs

2018-02-04 Thread Tim Peters
New submission from Tim Peters : This has come up repeatedly, and the docs should be updated to resolve it: https://stackoverflow.com/questions/48603998/python-iterating-over-a-list-but-i-want-to-add-to-that-list-while-in-the-loop/48604036#48604036 Seemingly the only relevant documentation is

[issue28685] Optimizing list.sort() by performing safety checks in advance

2018-01-28 Thread Tim Peters
Tim Peters added the comment: Thank you for giving this worthy orphan a home, Raymond! Victor, don't fret too much. The code is really quite simple, and at worst affects only `sorted()` and `list.sort()`. The vast bulk of review effort (of which it got enough) went into dreami

[issue28685] Optimizing list.sort() by performing safety checks in advance

2018-01-28 Thread Tim Peters
Tim Peters added the comment: I agree it would be nice (very!) to get this in. Indeed, I'm surprised to see that this is still open :-( But who can drive it? I cannot. -- ___ Python tracker <https://bugs.python.org/is

[issue32543] odd floor division behavior

2018-01-12 Thread Tim Peters
Tim Peters added the comment: This report appears to be the same: https://bugs.python.org/issue27463 One other thing to note: the Python docs are sometimes unclear about whether expressions are intended to be interpreted as Python code or as mathematical expressions. In: "&qu

[issue32509] doctest syntax ambiguity between continuation line and ellipsis

2018-01-07 Thread Tim Peters
Tim Peters added the comment: By the way, going back to your original problem, "the usual" solution to that different platforms can list directories in different orders is simply to sort the listing yourself. That's pretty easy in Python ;-) Then your test can verify the h

[issue32509] doctest syntax ambiguity between continuation line and ellipsis

2018-01-07 Thread Tim Peters
Tim Peters added the comment: Jason, an ellipsis will match an empty string. But if your expected output is: """ x... abcd ... """ you're asking for output that: - starts with "x" - followed by 0 or more of anything - FOLLOWED BY A NEWLINE (I t

[issue32509] doctest syntax ambiguity between continuation line and ellipsis

2018-01-06 Thread Tim Peters
Tim Peters added the comment: And I somehow managed to unsubscribe Steven :-( -- nosy: +steven.daprano ___ Python tracker <https://bugs.python.org/issue32

[issue32509] doctest syntax ambiguity between continuation line and ellipsis

2018-01-06 Thread Tim Peters
Tim Peters added the comment: Right, "..." immediately after a ">>>" line is taken to indicate a code continuation line, and there's no way to stop that short of rewriting the parser. The workaround you already found could be made more palatable if

[issue32382] Python mulitiprocessing.Queue fail to get according to correct sequence

2017-12-20 Thread Tim Peters
Tim Peters added the comment: First thing: the code uses the global name `outputer` for two different things, as the name of a module function and as the global name given to the Process object running that function. At least on Windows under Python 3.6.4 that confusion prevents the

[issue29710] Incorrect representation caveat on bitwise operation docs

2017-12-02 Thread Tim Peters
Tim Peters added the comment: To answer the old accusation ;-), no, this isn't my wording. I _always_ explain that Python's integer bit operations act as if the integers were stored in 2's-complement representation but with an infinite number of sign bits. That's

[issue32171] Inconsistent results for fractional power of -infinity

2017-11-30 Thread Tim Peters
Tim Peters added the comment: Mark, indeed, in the email from Vincent Lefevre you linked to, his entire argument was: (a) we already specified what happens when the base is a zero; so, (b) for each of the six pow(a_zero, y) cases we specified, derive a matching rule for an inf base via

[issue32171] Inconsistent results for fractional power of -infinity

2017-11-29 Thread Tim Peters
Tim Peters added the comment: No worries, Mark :-) Odd things happen sometimes when people are editing near the same time. BTW, of course I agree with closing this! -- ___ Python tracker <https://bugs.python.org/issue32

[issue32171] Inconsistent results for fractional power of -infinity

2017-11-29 Thread Tim Peters
Tim Peters added the comment: As a comment in the referenced patch says, the intent of the patch was to make behavior match the C99 spec. Among other things, C99's annex F (section F.9.4.4 "The pow functions") says: """ — pow(−∞, y) returns −0 for y an odd int

[issue32099] Use range in itertools roundrobin recipe

2017-11-20 Thread Tim Peters
Tim Peters added the comment: I agree the current recipe strikes a very nice balance among competing interests, and is educational on several counts. s/pending/numactive/ # Remove the iterator we just exhausted from the cycle. numactive -= 1 nexts = cycle(islice(nexts, numactive

[issue31630] math.tan has poor accuracy near pi/2 on OpenBSD and NetBSD

2017-11-20 Thread Tim Peters
Tim Peters added the comment: I have no opinion about any version of xxxBSD, because I've never used one ;-) If current versions of those do have this failure, has anyone opened a bug report on _their_ tracker(s)? I've seen no reason yet to imagine these failures are a fault

[issue31630] math.tan has poor accuracy near pi/2 on OpenBSD and NetBSD

2017-11-19 Thread Tim Peters
Tim Peters added the comment: Best I can tell, the fdlibm 5.3 on netlib was released in 2002, and essentially stopped existing as a maintained project then. Everyone else copied the source code, and made their own changes independently ever since :-( At least the folks behind the Julia

[issue32042] Option for comparing values instead of reprs in doctest

2017-11-19 Thread Tim Peters
Tim Peters added the comment: Tomáš, of course you can combine testing methods any way you like. Don't oversell this - there's nothing actually magical about comparing objects instead of strings ;-) I'm only -0 on this. It grates a bit against doctest's original intent

[issue32042] Option for comparing values instead of reprs in doctest

2017-11-19 Thread Tim Peters
Tim Peters added the comment: `doctest` is intended to be anal - there are few things more pointlessly confusing for a user than to see docs that don't match what they actually see when they run the doc's examples. "Is it a bug? Did I do it wrong? Why can't they docum

[issue31889] difflib SequenceMatcher ratio() still have unpredictable behavior

2017-11-03 Thread Tim Peters
Tim Peters added the comment: Pass "autojunk=False" to your SequenceMatcher constructor and the ratio you get back will continue to increase as `i` increases. The docs: """ Automatic junk heuristic: SequenceMatcher supports a heuristic that automatically treats

[issue31630] math.tan has poor accuracy near pi/2 on OpenBSD and NetBSD

2017-11-01 Thread Tim Peters
Tim Peters added the comment: Oops! I mixed up `sin` and `cos` in that comment. If it's argument reduction that's broken, then for x near pi/2 cos(x) will be evaluated as -sin(x - pi/2), which is approximately -(x - pi/2), and so error in argument reduction (the "x - pi/2&q

[issue31630] math.tan has poor accuracy near pi/2 on OpenBSD and NetBSD

2017-11-01 Thread Tim Peters
Tim Peters added the comment: Since fdlibm uses tan(x) ~= -1/(x-pi/2) in this range, and the reciprocals of the bad results have a whole of bunch of trailing zero bits, my guess is that argument reduction (the "x-pi/2" part) is screwing up (losing bits of pi/2 beyond the long

[issue31630] math.tan has poor accuracy near pi/2 on OpenBSD and NetBSD

2017-10-29 Thread Tim Peters
Tim Peters added the comment: BTW, has anyone tried running a tiny C program on these platforms to see what tan(1.5707963267948961) delivers? The kind of code fdlibm uses is sensitive not only to compiler (mis)optimization, but also to stuff like how the FPU's "precision contr

[issue31815] Make itertools iterators interruptible

2017-10-19 Thread Tim Peters
Tim Peters added the comment: Segfaults are different: they usually expose an error in CPython's implementation. We don't prioritize them because the user may have to restart their program (who cares? <0.5 wink>), but because they demonstrate the language implementation is

[issue31630] math.tan has poor accuracy near pi/2 on OpenBSD

2017-10-16 Thread Tim Peters
Tim Peters added the comment: On 16 Oct 2017, exactly the same test failures were reported on python-dev: https://mail.python.org/pipermail/python-dev/2017-October/149880.html >From the test output posted there: """ == CPython 3.6.3 (default, Oct 16 2017, 14:42:21) [GCC 4.7

[issue31759] re wont recover nor fail on runaway regular expression

2017-10-11 Thread Tim Peters
Tim Peters added the comment: Sure! The OP was obviously asking about the engine that ships with Python, so that's what I talked about. Raphaël, Matthew develops an excellent replacement ("regex") for Python's re module, which you can install via, e.g., "pip insta

[issue31759] re wont recover nor fail on runaway regular expression

2017-10-11 Thread Tim Peters
Tim Peters added the comment: Well, the problem in the regexp is this part: "\d+,? ?". You're not _requiring_ that strings of digits be separated by a comma or blank, you're only _allowing_ them to be so separated. A solid string of digits is matched by this,

[issue31327] bug in dateutil\tz\tz.py

2017-10-11 Thread Tim Peters
Tim Peters added the comment: I'll just add that it may be a different issue to argue about how `_naive_is_dst()` is implemented. -- nosy: +belopolsky ___ Python tracker <https://bugs.python.org/is

[issue31327] bug in dateutil\tz\tz.py

2017-10-11 Thread Tim Peters
Tim Peters added the comment: Since this is a pretty common gotcha, I'd prefer to add it as an example to the text I already quoted; e.g., add: """ For example, the native Windows C libraries do not support times before the epoch, and `localtime(n)` for negative `n`

[issue31327] bug in dateutil\tz\tz.py

2017-10-11 Thread Tim Peters
Tim Peters added the comment: The docs for the `time` module say: """ Although this module is always available, not all functions are available on all platforms. Most of the functions defined in this module call platform C library functions with the same name. It may sometime

[issue31630] math.tan has poor accuracy near pi/2 on OpenBSD

2017-10-02 Thread Tim Peters
Tim Peters added the comment: When Sun was developing fdlibm, I was (among other things) working on a proprietary libm for Kendall Square Research. I corresponded with fdlibm's primary author (KC Ng) often at the time. There's no way he would have left errors this egregious s

[issue31630] math.tan has poor accuracy near pi/2 on OpenBSD

2017-10-02 Thread Tim Peters
Tim Peters added the comment: Thanks for tanny-openbsd.txt, Serhiy! OpenBSD didn't get anywhere close to the best answer on any of those 201 inputs. I was hoping we could, e.g., test something a little more removed from pi/2 - but even its best cases in this range are hundreds of mil

[issue31630] math.tan has poor accuracy near pi/2 on OpenBSD

2017-10-02 Thread Tim Peters
Tim Peters added the comment: If someone opens a bug report with OpenBSD, or just for us to get more info, it could be useful to have a larger universe of troublesome tan inputs to stare at. So the attached tanny.py supplies them, testing all inputs within 100 ulps of math.pi/2 (or change N

[issue31630] math.tan has poor accuracy near pi/2 on OpenBSD

2017-10-01 Thread Tim Peters
Tim Peters added the comment: Ah! So it looks like OpenBSD took its math functions from Sun's fdlibm. I believe wxMaxima does too. That would certainly explain why they give the same answer ;-) So who's right? Using "bigfloats" in wxMaxima and feeding its bigfl

[issue31630] math.tan has poor accuracy near pi/2 on OpenBSD

2017-10-01 Thread Tim Peters
Tim Peters added the comment: Of course the relationship is extremely delicate near pi/2. On my Windows Python 3: >>> import math >>> (1.5707963267948961).hex() '0x1.921fb54442d16p+0' >>> math.tan(float.fromhex('0x1.921fb54442d16p+0')) # what t

[issue31646] bug in time.mktime

2017-09-30 Thread Tim Peters
Tim Peters added the comment: Note that 2am doesn't exist on the local clock: it leaps from 1:59:59 to 3:00:00. You're claiming that one answer is "correct", but why? The relevant _standards_ don't appear to specify what happens when the input is senseless. Not

[issue31561] difflib pathological behavior with mixed line endings

2017-09-24 Thread Tim Peters
Tim Peters added the comment: The text/binary distinction you have in mind doesn't particularly apply to difflib: it compares sequences of hashable objects. "Text files" are typically converted by front ends to lists of strings, but, e.g., the engine is just as happy comp

[issue31561] difflib pathological behavior with mixed line endings

2017-09-23 Thread Tim Peters
Tim Peters added the comment: I'm not familiar with `icdiff` - it's not part of the Python distribution, right? If so, you should really talk to its author(s). If two files have different line endings, then no pair of lines between them can be equal, and the difference engine wil

[issue31516] current_thread() becomes "dummy" thread during shutdown

2017-09-20 Thread Tim Peters
Tim Peters added the comment: Ya, it's clearly best for `current_thread()` to deliver consistent results. -- ___ Python tracker <https://bugs.python.org/is

[issue31517] MainThread association logic is fragile

2017-09-19 Thread Tim Peters
Tim Peters added the comment: Is there a problem here? I haven't heard of anyone even wondering about this before. threading.py worries about Threads created _by_ threading.py, plus the magical (from its point of view) thread that first imports threading.py. Users mix in `_thread` th

[issue14976] queue.Queue() is not reentrant, so signals and GC can cause deadlocks

2017-09-02 Thread Tim Peters
Tim Peters added the comment: [Guido] > Why was task management ever added? Raymond published a "joinable" queue class as a recipe here: http://code.activestate.com/recipes/475160-taskqueue/ and later folded it into the standard Python queue. So the usual answer applies: &q

[issue31186] Support heapfix() and heapremove() APIs in heapq module

2017-08-13 Thread Tim Peters
Tim Peters added the comment: @Rajath, I suspect Raymond may have been bamboozled because your suggested `heapfix()` and `heapremove()` didn't appear to take any arguments. If the index is a required argument, then these are O(log N) operations. I thought about adding them years ago

[issue31136] raw strings cannot end with a backslash character r'\'

2017-08-07 Thread Tim Peters
Tim Peters added the comment: Yes, I'm closing as not-a-bug. It's been this way (and documented) forever. More specifically, as the docs say, a raw string can't end with an _odd_ number of backslashes: """ String quotes can be escaped with a backslash, bu

[issue31063] List Comprehension Bug

2017-07-27 Thread Tim Peters
Tim Peters added the comment: This isn't a bug. 84 appears twice in the list, the first time at index 9. The .index() method finds the first (leftmost; smallest index) occurrence. Since 9 isn't even, the `if` test isn't satisfied, so 84 does not appear in the result.

[issue30907] speed up comparisons to self for built-in containers

2017-07-21 Thread Tim Peters
Tim Peters added the comment: Victor, this part of the docs explains what you're seeing; scroll down to the """ In enforcing reflexivity of elements, the comparison of collections assumes that for a collection element x, x == x is always true ... """ part.

[issue30965] Unexpected behavior of operator "in"

2017-07-18 Thread Tim Peters
Tim Peters added the comment: Not a bug. For an explanation, I just answered a very similar question on StackOverflow: https://stackoverflow.com/questions/45180899/unexpected-result-from-in-operator/45180967#45180899 -- nosy: +tim.peters

[issue30907] speed up comparisons to self for built-in containers

2017-07-14 Thread Tim Peters
Tim Peters added the comment: Ya, prior to now ;-) there's generally been some cost-benefit thought given to these things. Strings and ints are immutable and some values of each are uniquely interned, so the case of identity is more than just plausible. It happens often. I'd gues

[issue30907] speed up comparisons to self for built-in containers

2017-07-13 Thread Tim Peters
Tim Peters added the comment: Measuring in isolation (like with, e.g., timeit) isn't really interesting. Then everything is in L1 cache, branches are 100% predictable (because they take the same branch over & over for the duration of the test), and second-order effects on _other_

[issue30920] Sequence Matcher from diff lib is not implementing longest common substring problem correctly

2017-07-13 Thread Tim Peters
Tim Peters added the comment: This is an unfortunate consequence of the default "autojunk" feature. You can turn that off by passing `autojunk=False`, like so: match = SequenceMatcher(None, string1, string2, auto

[issue30907] speed up comparisons to self for built-in containers

2017-07-12 Thread Tim Peters
Tim Peters added the comment: Just noting that every special code path "at the start" doesn't just speed the case it's aiming at, it also _slows_ every case that doesn't pass the new tests. It takes time to fail the new tests. So it usually makes things slower over

[issue30880] PCG random number generator

2017-07-08 Thread Tim Peters
Tim Peters added the comment: I agree closing was appropriate at this time. I quite like PCG, but as Raymond said it's more a template for creating PRNGs than a specific generator. So even if a compelling case could be made, there's still a long way to having specific code in min

[issue29304] dict: simplify lookup functions

2017-06-25 Thread Tim Peters
Tim Peters added the comment: Oops! I undercounted the shifts in the current scheme: there's an additional shift for "perturb". That doesn't exist in the "double hashing" alternatives. -- ___ Python tracker <

[issue29304] dict: simplify lookup functions

2017-06-25 Thread Tim Peters
Tim Peters added the comment: I suggest reading the thread I started here[1] before pursuing this: it looks very likely that the entire collision resolution scheme should be replaced with one of the "double hashing" ones given there, a bona fide algorithmic improvement for small

[issue30671] dict: improve lookup function

2017-06-24 Thread Tim Peters
Tim Peters added the comment: Actually, there is something to be gained here, for smaller tables. The simple formulas for the expected number of probes under uniform hashing are upper bounds, and are significantly overstated when the load factor is very high (not a concern for Python) or the

[issue30671] dict: improve lookup function

2017-06-19 Thread Tim Peters
Tim Peters added the comment: BTW, I should have spelled this out earlier: recall that x and y collide on the first probe if and only if x = y (mod 2**k) [1] The second probe never happens unless they do collide on the first probe, so when looking at the second probe we can assume

[issue30671] dict: improve lookup function

2017-06-18 Thread Tim Peters
Tim Peters added the comment: Dmitry, I suggest you spend more of the time you give to thinking to writing code instead ;-) But, really, that's the easiest & surest way to discover for yourself where your analysis is going off in the weeds. For example, issue 28201 was both simpler

[issue30671] dict: improve lookup function

2017-06-18 Thread Tim Peters
Tim Peters added the comment: I don't see a reason to keep this open, but I haven't been able to follow the OP's line of argument. My best _guess_ is that they're chasing illusions based on not understanding (or grossly undervaluing) that the primary point of the

[issue30671] dict: improve lookup function

2017-06-17 Thread Tim Peters
Tim Peters added the comment: The attached hashsim.py pretty much convinces me there's nothing left to be gained here. It shows that the current scheme essentially achieves the performance of theoretical "uniform hashing" for string keys, for both successful and unsuccessf

[issue30671] dict: improve lookup function

2017-06-16 Thread Tim Peters
Tim Peters added the comment: Yes, any scheme whatsoever that guarantees to visit every int in range(2**i) meets the "correctness" part. But I concur with Inada: "head arguments" aren't compelling here, not even if I understood what they were saying ;-) If you imp

[issue30671] dict: simplify and improve lookup function

2017-06-15 Thread Tim Peters
Tim Peters added the comment: Whatever the iteration, accept that it's necessary it reach every value in range(2**i) eventually. The current scheme does that, for reasons already documented. You seem to be overlooking the importance of this part: """ Note that because

[issue30346] Odd behavior when unpacking `itertools.groupby`

2017-05-13 Thread Tim Peters
Tim Peters added the comment: Users certainly have been fooled by this, although "unpacking" is a red herring. I've been burned by it, and I've seen StackOverflow puzzles related to the same thing. I think this is the heart of it: given a finite iterable I, it usual

[issue30311] random.shuffle pointlessly shuffles dicts

2017-05-08 Thread Tim Peters
Tim Peters added the comment: Generally speaking, trying to shuffle a dict D already blows up, unless D's keys are the integers range(len(D)). In that case, D is indistinguishable from a list in the sense that both map range(N) to values via __getitem__. `shuffle()` does no type c

[issue30174] Duplicate code in pickletools.py

2017-04-26 Thread Tim Peters
Tim Peters added the comment: I already commented on github - +1 for this change. -- nosy: +tim.peters ___ Python tracker <http://bugs.python.org/issue30

[issue30148] Pathological regex behaviour

2017-04-24 Thread Tim Peters
Tim Peters added the comment: Yes, that example takes time exponential in the number of blanks to (fail to) match - each time you add a blank to `input`, it essentially doubles the time required. It's _possible_ for an implementation to deduce that `(\s+)+` is an insanely inefficient w

[issue5906] Risk of confusion in multiprocessing module - daemonic processes

2017-04-01 Thread Tim Peters
Tim Peters added the comment: Again, I don't care about orphans. In the usual cases people are running code with no concern about what happens in case of forced termination. The only thing stopping it now is that the code goes out of its way to prevent it (or, alternatively, goes out o

[issue5906] Risk of confusion in multiprocessing module - daemonic processes

2017-04-01 Thread Tim Peters
Tim Peters added the comment: @Eryk, not me ;-) I find the "daemonic or not?" distinction useless for processes - it just gets in the way at times (e.g., a Pool worker dies with an assert(!) error if it tries to create its own Pool for something). I don't care about orphans ei

[issue5906] Risk of confusion in multiprocessing module - daemonic processes

2017-04-01 Thread Tim Peters
Tim Peters added the comment: I'll take a crack at these ancient comments ;-) """ daemon The process’s daemon flag, a Boolean value. This must be set before start() is called. The initial value is inherited from the creating process. [1] When a process e

[issue29941] Confusion between asserts and Py_DEBUG

2017-03-30 Thread Tim Peters
Tim Peters added the comment: So there's more than one issue here. First, should asserts be supported in the absence of Py_DEBUG? It seems, so far, everyone agrees they should be. Second, ...? I'm really not following your argument. It _appears_ to be something along the lines

[issue29941] Confusion between asserts and Py_DEBUG

2017-03-29 Thread Tim Peters
Tim Peters added the comment: I think we should certainly support asserts regardless of whether Py_DEBUG is in force (although Py_DEBUG should imply asserts run too). And I wish you had stuck to just that much ;-) The argument against, e.g., 'assert(!PyErr_Occurred())', seems e

[issue29882] Add an efficient popcount method for integers

2017-03-22 Thread Tim Peters
Tim Peters added the comment: See also: https://en.wikipedia.org/wiki/Hamming_weight As that says, there are a number of languages and processors with first class support for a popcount function. I've frequently implemented it in Python when using integers as integer bitsets (`i`

[issue28685] Optimizing list.sort() by performing safety checks in advance

2017-03-12 Thread Tim Peters
Tim Peters added the comment: @ppperry, I believe you're right - good catch! I expect the current patch would treat the NotImplemented return as meaning "the first argument is less than the second argument". I added a comment to the code (on github) suggesting an obvio

[issue29797] Deadlock with multiprocessing.Queue()

2017-03-12 Thread Tim Peters
Changes by Tim Peters : -- resolution: -> not a bug stage: -> resolved status: open -> closed ___ Python tracker <http://bugs.python.org/issue29797> ___ ___

[issue29797] Deadlock with multiprocessing.Queue()

2017-03-11 Thread Tim Peters
Tim Peters added the comment: I think this is expected. Add this as the first line of `simulate()` and the problem should go away: q.cancel_join_thread() As the docs say, a Queue works with a background thread, which feeds incoming data from an internal buffer to a (interprocess) pipe

[issue28685] Optimizing list.sort() by performing safety checks in advance

2017-03-11 Thread Tim Peters
Tim Peters added the comment: Elliot, PyObject_RichCompareBool calls PyObject_RichCompare. That in turn does some checks, hides a small mountain of tests in the expansions of the recursion-checking macros, and calls do_richcompare. That in turn does some useless (in the cases you're a

[issue28685] Optimizing list.sort() by performing safety checks in advance

2017-03-11 Thread Tim Peters
Tim Peters added the comment: The impact would be small: it would add one (or so) pointer-equality compare that, in practice, will always say "yup, they're equal". Dirt cheap, and the branch is 100% predictable. -- ___ Python

[issue28685] Optimizing list.sort() by performing safety checks in advance

2017-03-11 Thread Tim Peters
Tim Peters added the comment: Elliot, did you run the example in a release build or a debug build? I'm wondering why this: assert(v->ob_type == w->ob_type && v->ob_type->tp_richcompare != NULL && v->ob_type->tp_richcompare == compa

[issue28685] Optimizing list.sort() by performing safety checks in advance

2017-03-11 Thread Tim Peters
Tim Peters added the comment: Elliot, I don't care if the example behaves differently. Although someone else may ;-) The only things `.sort()` has ever tried to guarantee in the presence of mutations (of either the list or the elements) during sorting are that (a) the implementation

[issue28685] Optimizing list.sort() by performing safety checks in advance

2017-03-11 Thread Tim Peters
Tim Peters added the comment: @ppperry, I have no idea what the bulk of the code in typeobect.c is trying to do. -- ___ Python tracker <http://bugs.python.org/issue28

[issue28685] Optimizing list.sort() by performing safety checks in advance

2017-03-11 Thread Tim Peters
Tim Peters added the comment: I haven't tried the example, but at this point I'd be surprised if it failed. The caching here isn't at level of `__lt__` but at the higher level of (invisible from Python code) a type's tp_richcompare slot. A heap type - regardless of wheth

[issue29754] sorted ignores reverse=True when sorting produces same list

2017-03-07 Thread Tim Peters
Tim Peters added the comment: Your last line can't possibly return True, because `somelist.reverse()` returns None. So the last line is irrelevant. Your complaint appears to be about the line before, which shows that the list retains its original order. That's expected. All th

[issue29449] clear() should return prior state in threading.Event

2017-02-07 Thread Tim Peters
Tim Peters added the comment: I can't judge a use case for a thread gimmick in the absence of wholly specified examples. There are too many possible subtleties. Indeed, if I'd do anything with Event.clear() it would be to remove it - I've seen too much code that suffers s

[issue29016] negative numbers raised to power zero should be 1, not -1

2016-12-19 Thread Tim Peters
New submission from Tim Peters: They already are. >>> (-2)**0 1 You're probably doing this instead: >>> -2**0 -1 Exponentiation has higher precedence than unary minus, so that last example groups as -(2**0), and -1 is correct. -- nosy: +tim.peters resoluti

[issue28800] Add RETURN_NONE bytecode instruction

2016-11-27 Thread Tim Peters
Tim Peters added the comment: I also don't see a good reason to keep this open now - adds complication for no quantifiable payoff. -- ___ Python tracker <http://bugs.python.org/is

[issue28579] nan != nan

2016-11-01 Thread Tim Peters
Tim Peters added the comment: Yes, it's both intended and annoying ;-) The standard specifies that, by default, comparisons involving NANs are "unordered": a NAN is _none_ of "less than", "equal to", or "greater than" any other float, i

[issue28529] 0 ** 0 should raise ArithmeticError

2016-10-25 Thread Tim Peters
Tim Peters added the comment: This won't be changed - it's a near-universally mandated behavior across relevant standards. Many years ago it wasn't, but Knuth changed minds when he wrote: """ We must define x^0=1 for all x, if the binomial theorem is to be valid

[issue28506] Multiprocessing Pool starmap - struct.error: 'i' format requires -2e10<=n<=2e10

2016-10-22 Thread Tim Peters
Tim Peters added the comment: This has nothing to do with the _values_ you're passing - it has to do with the length of the pickle string: def _send_bytes(self, buf): n = len(buf) # For wire compatibility with 3.2 and lower header = struct.pack("!i&

[issue26163] FAIL: test_hash_effectiveness (test.test_set.TestFrozenSet)

2016-10-20 Thread Tim Peters
Tim Peters added the comment: I think Raymond will have to chime in. I assume this is due to the `letter_range` portion of the test suffering hash randomization dealing it a bad hand - but the underlying string hash is "supposed to be" strong regardless of seed. The self.ass

[issue28423] list.insert(-1,value) is wrong!

2016-10-12 Thread Tim Peters
Tim Peters added the comment: It's fine. Read the docs. "s.insert(i, x) inserts x into s at the index given by i (same as s[i:i] = [x])" Note that: >>> fred[-1:] [4] So the empty slice s[-1:-1] is _between_ 3 and 4 in `fred`. If you're not surprised by >&

[issue28201] dict: perturb shift should be done when first conflict

2016-10-05 Thread Tim Peters
Tim Peters added the comment: LGTM! Ship it :-) -- ___ Python tracker <http://bugs.python.org/issue28201> ___ ___ Python-bugs-list mailing list Unsubscribe:

<    3   4   5   6   7   8   9   10   11   12   >