You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Improve performance for list.insert() and del list[i] in free-threaded builds #158790
ins1()(used by list.insert()) and list_ass_item_lock_held() shift the list with one atomic release store per element in free-threaded builds. Those atomic stores prevent the compiler from vectorizing the loops, making them much slower than memmove() for large shifts. I propose using the existing ptr_wise_atomic_memmove() helper here. It uses memmove() as a fast path when the list is owned by the current thread and is not shared, and keeps the atomic element-wise stores for lists that other threads can observe.
The default (GIL) build keeps the current loops because the compiler can optimize them directly in the calling function, and they perform better in benchmarks.
Activity
hetaozdh commentedon Oct 4, 2026
The benchmark is produced by AI and verified by me.
pythongh-158790: Address review comments
pythongh-158790: Move the list shift logic into helpers
gh-158790: Improve performance for list.insert() and del list[i] free…
corona10 commentedon Oct 7, 2026
Thanks @hetaozdh