Skip to content

del list[index] never reallocates the array #158592

Description

@x42005e1f

Bug report

This works as expected:

>>> import sys
>>> seq = list(range(1000))
>>> sys.getsizeof(seq)
8056
>>> for _ in range(1000):
...     seq.pop()
>>> sys.getsizeof(seq)
56

But this does not:

>>> import sys
>>> seq = list(range(1000))
>>> sys.getsizeof(seq)
8056
>>> for _ in range(1000):
...     del seq[-1]
>>> sys.getsizeof(seq)
8056

Perhaps a regression from #115605 (note that the list_ass_slice() call has been replaced with a separate implementation).

CPython versions tested on:

3.13, 3.14, 3.15, CPython main branch

Operating systems tested on:

Linux

Linked PRs

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.14bugs and security fixes3.15pre-release feature fixes, bugs and security fixes3.16new features, bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usagetype-bugAn unexpected behavior, bug, or errortype-featureA feature request or enhancementtype-refactorCode refactoring (with no changes in behavior)

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions