cpython icon indicating copy to clipboard operation
cpython copied to clipboard

Clarify clamping specifications for `sequence.insert`

Open yousef-fadli opened this issue 2 weeks ago • 8 comments

https://docs.python.org/3.14/library/array.html#array.array.insert

The documentation for array.array.insert(i, x) does not specify what happens when i is greater than the length of the array. for example :

import array

my_array = array.array("i", [1, 2, 3])
my_array.insert(10**9, 4)
print(my_array)

clarifying this behavior in the documentation improves consistency and removes ambiguity

Linked PRs

  • gh-143422

yousef-fadli avatar Jan 04 '26 21:01 yousef-fadli