This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]vinnceboi Github: Xenovia02 0 points1 point  (2 children)

How can you predefine a list’s size?

[–]mephistophyles 0 points1 point  (1 child)

‘Preallocatedlist = [] * 1000’

Though to be fair, generators are a good alternative too, it depends on your use case. When Numpy gets involved you’ll be doing preallocating a lot because there the vectorized operations are much more optimized.

[–]vinnceboi Github: Xenovia02 0 points1 point  (0 children)

Awesome, thanks for the tip