[issue45001] Date parsing helpers in email module incorrectly raise IndexError for some malformed inputs

2021-08-25 Thread wouter bolsterlee
wouter bolsterlee added the comment: pull request with fix at https://github.com/python/cpython/pull/27946 -- keywords: +patch message_count: 1.0 -> 2.0 pull_requests: +26392 stage: -> patch review pull_request: https://github.com/python/cpython/pull

[issue45001] Date parsing helpers in email module incorrectly raise IndexError for some malformed inputs

2021-08-25 Thread wouter bolsterlee
New submission from wouter bolsterlee : Various date parsing utilities in the email module, such as email.utils.parsedate(), are supposed to gracefully handle invalid input, typically by raising an appropriate exception or by returning None. The internal email._parseaddr._parsedate_tz

[issue35701] [uuid] 3.8 breaks weak references for UUIDs

2019-01-14 Thread wouter bolsterlee
wouter bolsterlee added the comment: the test could be sth like x = uuid.uuid4() y = weakref.ref(x) assert x is y() -- ___ Python tracker <https://bugs.python.org/issue35

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

2017-07-21 Thread wouter bolsterlee
Changes by wouter bolsterlee <u...@xs4all.nl>: -- resolution: -> rejected stage: -> resolved status: open -> closed ___ Python tracker <rep...@bugs.python.org> <http://bu

[issue30977] reduce uuid.UUID() memory footprint

2017-07-21 Thread wouter bolsterlee
wouter bolsterlee added the comment: i consider uuids as low level data types, not as fancy containers, similar to how i view datetime objects. given the native support in e.g. postgresql and many other systems, it's common to deal with uuids. of course you can convert to/from strings

[issue30977] reduce uuid.UUID() memory footprint

2017-07-20 Thread Wouter Bolsterlee
Wouter Bolsterlee added the comment: as a follow-up note, i also experimented with keeping the actual value as a bytes object instead of an integer, but that does not lead to less memory being used: a 128-bit integer uses less memory than a 16 byte bytes object (presumably because

[issue30977] reduce uuid.UUID() memory footprint

2017-07-20 Thread Wouter Bolsterlee
New submission from Wouter Bolsterlee: memory usage for uuid.UUID seems larger than it has to be. it seems that using __slots__ will save around ~100 bytes per instance, which is very significant, e.g. when dealing with large sets of uuids (which are often used as "primary keys" int

[issue30977] reduce uuid.UUID() memory footprint

2017-07-20 Thread Wouter Bolsterlee
Changes by Wouter Bolsterlee <u...@xs4all.nl>: -- pull_requests: +2835 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue30977> ___ _

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

2017-07-13 Thread Wouter Bolsterlee
Wouter Bolsterlee added the comment: fwiw, "if (PyDict_CheckExact(a) && a == b)" amounts to two pointer comparisons, the overhead of which is too small to measure. (i tried.) -- ___ Python tracker <rep...@bugs.python.org>

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

2017-07-12 Thread Wouter Bolsterlee
Changes by Wouter Bolsterlee <u...@xs4all.nl>: -- pull_requests: +2745 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue30907> ___ _

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

2017-07-12 Thread Wouter Bolsterlee
New submission from Wouter Bolsterlee: when comparing instances of the built-in container types (dict, list, and others) python assumes that "identity implies equality". this is documented (and assumed) behaviour: "In enforcing reflexivity of elements, the comparison of coll

[issue23493] optimize sort_keys in json module by using operator.itemgetter()

2015-02-23 Thread Wouter Bolsterlee
Wouter Bolsterlee added the comment: Using IPython and CPython 3.4: d = dict.fromkeys(map(str, range(1000))) Current implementation: %timeit sorted(d.items(), key=lambda kv: kv[0]) 1000 loops, best of 3: 605 µs per loop %timeit sorted(d.items(), key=lambda kv: kv[0]) 1000 loops, best of 3

[issue23493] optimize sort_keys in json module by using operator.itemgetter()

2015-02-20 Thread Wouter Bolsterlee
New submission from Wouter Bolsterlee: The JSON encoder uses a lambda function for the sort(key=...) invocation used to sort the keys in a JSON object in case sort_keys=True is passed: https://hg.python.org/cpython/file/46bfddb14cbe/Lib/json/encoder.py#l352 Instead of having a lambda

[issue18962] Add special case for single iterator in heapq.merge function

2013-09-11 Thread Wouter Bolsterlee
Wouter Bolsterlee added the comment: Thanks for the quick response. Btw, do I understand correctly code cleanups are not welcome, even when touching the code anyway? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18962

[issue18962] Add special case for single iterator in heapq.merge function

2013-09-11 Thread Wouter Bolsterlee
Wouter Bolsterlee added the comment: (In case you missed it: my latest comment included a cleaned up version of an earlier patch.) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18962

[issue18962] Add special case for single iterator in heapq.merge function

2013-09-10 Thread Wouter Bolsterlee
Wouter Bolsterlee added the comment: Thanks Raymond, that is exactly what I had in mind (see my previous comment). Here's a slightly cleaned up version of the patch (stylistic/PEP8 cleanups), with some benchmarks included below. In case the two longest iterators have about the same size

[issue18962] Add special case for single iterator in heapq.merge function

2013-09-08 Thread Wouter Bolsterlee
Wouter Bolsterlee added the comment: An additional speedup would be to add a if len(h) == 1 check inside the while loop, and just yield from the remaining iterator if a single iterable remains. This would also speed up merges with multiple inputs, as it doesn't do the whole heapreplace() loop

[issue18962] Add special case for single iterator in heapq.merge function

2013-09-07 Thread Wouter Bolsterlee
New submission from Wouter Bolsterlee: The heapq.merge() function merges multiple sorted iterables into a single sorted output. The function uses a heap queue that is repeatedly looped over until it has generated all output. If only a single iterable is passed to heapq.merge(), the heap