[issue39737] Speed up list.__eq__ by about 6%

2020-02-23 Thread Dennis Sweeney
New submission from Dennis Sweeney : The following tiny change: diff --git a/Objects/listobject.c b/Objects/listobject.c index 3c39c6444b..3ac03b71d0 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -2643,8 +2643,7 @@ list_richcompare(PyObject *v, PyObject *w, int op

[issue39657] Bezout and Chinese Remainder Theorem in the Standard Library?

2020-02-16 Thread Dennis Sweeney
New submission from Dennis Sweeney : Should something like the following go in the standard library, most likely in the math module? I know I had to use such a thing before pow(a, -1, b) worked, but Bezout is more general. And many of the easy stackoverflow implementations of CRT congruence

[issue39648] Update math.gcd() to accept "n" arguments.

2020-02-16 Thread Dennis Sweeney
Dennis Sweeney added the comment: Correction correction: returning zero preserves the invariant below. from math import gcd as GCD from functools import reduce from itertools import starmap, chain def gcd(*args): return reduce(GCD, args, 0) iterables = [[10, 20, 30

[issue39648] Update math.gcd() to accept "n" arguments.

2020-02-16 Thread Dennis Sweeney
Dennis Sweeney added the comment: Correction: gcd(itertools.chain(iterables)) == gcd(*map(gcd, iterables)) -- ___ Python tracker <https://bugs.python.org/issue39

[issue39648] Update math.gcd() to accept "n" arguments.

2020-02-16 Thread Dennis Sweeney
Dennis Sweeney added the comment: I think the behavior of gcd() == 0 is correct, but it should be documented, because it isn't completely obvious. Arguments for gcd() == 0: - Preserves the invariant gcd(itertools.chain(iterables)) == gcd(itertools.starmap(gcd, iterables)) in the case

[issue38938] Possible performance improvement for heaqq.merge()

2020-02-09 Thread Dennis Sweeney
Change by Dennis Sweeney : -- pull_requests: +17803 pull_request: https://github.com/python/cpython/pull/18427 ___ Python tracker <https://bugs.python.org/issue38

[issue39590] collections.deque.__contains__ and .count should hold strong references.

2020-02-08 Thread Dennis Sweeney
Dennis Sweeney added the comment: Should there be a similar generic test case in test.seq_test? -- ___ Python tracker <https://bugs.python.org/issue39

[issue39590] collections.deque.__contains__ and .count should hold strong references.

2020-02-08 Thread Dennis Sweeney
Change by Dennis Sweeney : -- keywords: +patch pull_requests: +17796 stage: -> patch review pull_request: https://github.com/python/cpython/pull/18421 ___ Python tracker <https://bugs.python.org/issu

[issue39590] collections.deque.__contains__ and .count should hold strong references.

2020-02-08 Thread Dennis Sweeney
New submission from Dennis Sweeney : Similar to https://bugs.python.org/issue39453, but with deques: Python 3.9.0a3+: >>> from collections import deque >>> class A: ... def __eq__(self, other): ... L.clear() ... return NotImplemented ... >>> L =

[issue38938] Possible performance improvement for heaqq.merge()

2019-12-28 Thread Dennis Sweeney
Dennis Sweeney added the comment: PR 17729 is a C implementation of a non-recursive "flattening" of the the recursive-lazy-mergesort algorithm into a tournament whose state is a tree of losers of comparisons. -- ___ Python track

[issue38938] Possible performance improvement for heaqq.merge()

2019-12-28 Thread Dennis Sweeney
Change by Dennis Sweeney : -- pull_requests: +17174 pull_request: https://github.com/python/cpython/pull/17729 ___ Python tracker <https://bugs.python.org/issue38

[issue38938] Possible performance improvement for heaqq.merge()

2019-11-30 Thread Dennis Sweeney
Change by Dennis Sweeney : -- keywords: +patch pull_requests: +16903 stage: -> patch review pull_request: https://github.com/python/cpython/pull/17422 ___ Python tracker <https://bugs.python.org/issu

[issue38938] Iterable merge performance and inclusion in itertools

2019-11-30 Thread Dennis Sweeney
Dennis Sweeney added the comment: Disregard merge_recipe.py: it would skip over a value that had already been retrieved from the iterator when the loop finished. -- ___ Python tracker <https://bugs.python.org/issue38

[issue38938] Iterable merge performance and inclusion in itertools

2019-11-28 Thread Dennis Sweeney
Dennis Sweeney added the comment: The following seems like it is a short, readable recipe for itertools. -- Added file: https://bugs.python.org/file48748/merge_recipe.py ___ Python tracker <https://bugs.python.org/issue38

[issue38938] Iterable merge performance and inclusion in itertools

2019-11-28 Thread Dennis Sweeney
New submission from Dennis Sweeney : Although the implementation of the heapq.merge function uses an underlying heap structure, its behavior centers on iterators. For this reason, I believe there should either be an alias to this function in the itertools module or at least a recipe

[issue37004] SequenceMatcher.ratio() noncommutativity not well-documented

2019-05-21 Thread Dennis Sweeney
New submission from Dennis Sweeney : I understand that the SequenceMatcher's ratio method does not guarantee that SequenceMatcher(None, a, b).ratio() == SequenceMatcher(None, b, a).ratio(). Below is a counterexample: # Example from https://mail.python.org/pipermail/python-list/2010

<    1   2   3   4   5   6