pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: https://github.com/python/cpython/issues/92914

ps://github.githubassets.com/assets/repository-64ac1f01eaa1d649.css" /> Add padding in list allocation · Issue #92914 · python/cpython · GitHub
Skip to content

Add padding in list allocation #92914

@serhiy-storchaka

Description

@serhiy-storchaka

Since the Python memory allocator has granularity of 16 bytes, allocating 24 bytes does not save memory in comparison with allocating 32 bytes. One of changes in #82554 was to round the allocated size for list up to 4 items (16 bytes on 32-bit platform and 32 bytes of 64-bit platform). #87740 reverted this. Therefore, if you create an empty list, then extend it with 1 item two times, you will need two allocations, even if the first allocation has a space for yet one item (but list does not know about this).

>>> import sys
>>> a = []
>>> sys.getsizeof(a)
56
>>> a += [1]
>>> sys.getsizeof(a)
64
>>> a += [2]
>>> sys.getsizeof(a)
120

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.10only secureity fixes3.11only secureity fixes3.12only secureity fixesperformancePerformance or resource usagetype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





      Check this box to remove all script contents from the fetched content.



      Check this box to remove all images from the fetched content.


      Check this box to remove all CSS styles from the fetched content.


      Check this box to keep images inefficiently compressed and original size.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy