[issue39829] __len__ called twice in the list() constructor

2022-03-13 Thread Inada Naoki
Inada Naoki added the comment: Thanks. -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue39829] __len__ called twice in the list() constructor

2022-03-13 Thread Inada Naoki
Change by Inada Naoki : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker ___ ___

[issue39829] __len__ called twice in the list() constructor

2022-03-13 Thread Inada Naoki
Inada Naoki added the comment: New changeset 2153daf0a02a598ed5df93f2f224c1ab2a2cca0d by Crowthebird in branch 'main': bpo-39829: Fix `__len__()` is called twice in list() constructor (GH-31816) https://github.com/python/cpython/commit/2153daf0a02a598ed5df93f2f224c1ab2a2cca0d --

[issue39829] __len__ called twice in the list() constructor

2022-03-13 Thread Irit Katriel
Change by Irit Katriel : -- versions: -Python 3.8 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue39829] __len__ called twice in the list() constructor

2022-03-13 Thread Jeremiah Pascual
Change by Jeremiah Pascual : -- versions: +Python 3.10, Python 3.11 ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue39829] __len__ called twice in the list() constructor

2022-03-12 Thread Jeremiah Pascual
Jeremiah Pascual added the comment: > Looks good to me. Would you create a pull request? Created a pull request (31816). -- ___ Python tracker ___

[issue39829] __len__ called twice in the list() constructor

2022-03-11 Thread Jeremiah Pascual
Change by Jeremiah Pascual : -- keywords: +patch pull_requests: +29914 stage: -> patch review pull_request: https://github.com/python/cpython/pull/31816 ___ Python tracker

[issue39829] __len__ called twice in the list() constructor

2022-03-10 Thread Inada Naoki
Inada Naoki added the comment: > Changes compared here: > https://github.com/python/cpython/compare/main...thatbirdguythatuknownot:patch-17 Looks good to me. Would you create a pull request? -- ___ Python tracker

[issue39829] __len__ called twice in the list() constructor

2022-03-10 Thread Jeremiah Pascual
Jeremiah Pascual added the comment: Matt's idea leads to some speedups when implemented correctly (pardon me but I have no idea how to use pyperf): list({}): Mean +- std dev: [orig] 109 ns +- 1 ns -> [modif] 103 ns +- 1 ns: 1.06x faster list({1: 2}): Mean +- std dev: [orig] 125 ns +- 1 ns

[issue39829] __len__ called twice in the list() constructor

2022-03-07 Thread Inada Naoki
Change by Inada Naoki : -- nosy: +methane ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue39829] __len__ called twice in the list() constructor

2022-03-07 Thread Dennis Sweeney
Dennis Sweeney added the comment: Related to Matt's idea is https://bugs.python.org/issue43574 -- nosy: +Dennis Sweeney ___ Python tracker ___

[issue39829] __len__ called twice in the list() constructor

2022-03-07 Thread Matt Wozniski
Matt Wozniski added the comment: Pardon me for necroing an old issue, but someone pointed out the surprising behavior of `__len__` being called twice by `list(iterable)`, and it caught my curiosity. https://github.com/python/cpython/commit/372d705d958964289d762953d0a61622755f5386 made it

[issue39829] __len__ called twice in the list() constructor

2020-03-09 Thread Eric Snow
Eric Snow added the comment: I'm not opposed. :) I just don't want to impose on your time. -- assignee: -> pablogsal resolution: not a bug -> stage: resolved -> status: closed -> open ___ Python tracker

[issue39829] __len__ called twice in the list() constructor

2020-03-09 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: Thanks Kim and Eric! I think it still makes sense to do some quick benchmarking and research on passing down the calculated length. I can try to produce a draft PR so we can discuss with something more tangible. --

[issue39829] __len__ called twice in the list() constructor

2020-03-09 Thread Eric Snow
Eric Snow added the comment: FWIW, I encouraged Kim to file this. Thanks Kim! While it isn't part of any specification, it is an unexpected change in behavior that led to some test failures. So I figured it would be worth bringing up. :) I did find it surprising that we were not caching

[issue39829] __len__ called twice in the list() constructor

2020-03-07 Thread Terry J. Reedy
Terry J. Reedy added the comment: The only specification is that len(ob) calls ob.__len__ and that ob.__len__ should return an 'integer >= 0'. (Adding side effects goes beyond that spec.) I agree that a detectable internal in list is not a bug. Unless there is a realistic performance

[issue39829] __len__ called twice in the list() constructor

2020-03-02 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: Why should that be backwards incompatible? The number of times we can `__len__` on the constructor is an implementation detail. The reason is called now twice is because there is an extra check for the preallocation logic, which is detached from the

[issue39829] __len__ called twice in the list() constructor

2020-03-02 Thread Kim-Adeline Miguel
New submission from Kim-Adeline Miguel : (See #33234) Recently we added Python 3.8 to our CI test matrix, and we noticed a possible backward incompatibility with the list() constructor. We found that __len__ is getting called twice, while before 3.8 it was only called once. Here's an