On Fri, Oct 8, 2021 at 12:55 PM Daniel Pope <lord.mauve@gmail.com> wrote:
I'm a novice C programmer, but I'm unsure about the safety of your
thread-safe collections description.

The "list" class uses a slightly different strategy than "dict", which I forgot about
when writing the design overview. List relies on the property that the backing array
of a given list can only grow (never shrink) [1]. This is different from upstream CPython.

Dict stores the capacity inside PyDictKeysObject (the backing array). The capacity
never changes, so if you have a valid pointer to the PyDictKeysObject you load the
correct capacity.

I've been meaning to change "list" to use the same strategy as "dict". I think that would
simplify the overall design and let "list" shrink the backing array again.
[1] https://github.com/colesbury/nogil/blob/fb6aabede5f7f1936a21c2f48ec7fcc0848d74bf/Objects/listobject.c#L46-L49 (