The Python Oracle

What causes [*a] to overallocate?

Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn

--

Music by Eric Matyas
https://www.soundimage.org
Track title: Puzzle Game 3 Looping

--

Chapters
00:00 Question
01:42 Accepted answer (Score 86)
04:06 Answer 2 (Score 18)
06:20 Answer 3 (Score 8)
07:02 Thank you

--

Full question
https://stackoverflow.com/questions/6054...

Question links:
[image]: https://i.stack.imgur.com/SOZoe.png
[reproducable at repl.it]: https://repl.it/repls/CoordinatedUnsungS...
[Colab with data and code]: https://colab.research.google.com/drive/...
[image]: https://i.stack.imgur.com/7F3Ba.png
[image]: https://i.stack.imgur.com/xwhob.png

Accepted answer links:
[is internally doing the C equivalent of]: https://github.com/python/cpython/blob/3...
[Try it online!]: https://tio.run/##fY3BCsMgEETvfsUeNYRCya...
[Python recently fixed a bug that made the constructor overallocate even for inputs with known size]: https://bugs.python.org/issue33234

Answer 2 links:
[ShadowRanger's answer]: https://stackoverflow.com/a/60551320/167...
[in ]: https://github.com/python/cpython/blob/6...
[uses]: https://github.com/python/cpython/blob/e...
[calls ]: https://github.com/python/cpython/blob/e...
[overallocates]: https://github.com/python/cpython/blob/e...
[shortcuts]: https://github.com/python/cpython/blob/e...

Answer 3 links:
https://github.com/python/cpython/blob/m...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #python3x #list #cpython #pythoninternals

#avk47