Python lists remember what you did to them

Опубликовано: 13 Февраль 2022
на канале: mCoding
127,735
4.7k

Two equal lists can take differrent amounts of memory!

Two Python lists of the same size can take different amounts of memory, even if they contain exactly the same elements. A larger list can even take less memory than a smaller list. How can this be? Lists appear to remember more than just their elements, and somehow contain some information of their history. In this video we investigate this phenomenon. We see what the system getsizeof function returns and how the internal structure of a list is represented in order to find the answer.

― mCoding with James Murphy (https://mcoding.io)

Source code: https://github.com/mCodingLLC/VideosS...
libcst: https://libcst.readthedocs.io/en/late...
AST linting vid:    • Python AST Parsing and Custom Linting  
Structural pattern matching vid:    • The Hottest New Feature Coming In Pyt...  

SUPPORT ME ⭐
---------------------------------------------------
Patreon:   / mcoding  
Paypal: https://www.paypal.com/donate/?hosted...
Other donations: https://mcoding.io/donate

Top patrons and donors: Jameson, Laura M, Dragos C, Vahnekie, John Martin, Casey G

BE ACTIVE IN MY COMMUNITY 😄
---------------------------------------------------
Discord:   / discord  
Github: https://github.com/mCodingLLC/
Reddit:   / mcoding  
Facebook:   / james.mcoding  

CHAPTERS
---------------------------------------------------
0:00 Intro
1:01 Let's investigate
3:04 Under the hood of a list
4:23 How sys.getsizeof is calculated
5:06 Capacity
6:13 Why capacity != length
7:08 Geometric resizing
7:34 The answer in terms of capacities
9:19 Reality check
9:49 Thanks


Смотрите видео Python lists remember what you did to them онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь mCoding 13 Февраль 2022, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 127,735 раз и оно понравилось 4.7 тысяч людям.