Delete item from PyDict by exact value and hash - Python technicalities

Skip to content
Back to top
View this page
Edit this page

# Delete item from PyDict by exact value and hash

Beware that the implementation of the routine here relies on implementation details of CPython’s dict that go beyond the published API.

AUTHORS:

- Nils Bruin (2017-05)

sage.cpython.dict_del_by_value.test_del_dictitem_by_exact_value(D, value, h)

  This function helps testing some cdef function used to delete dictionary items.

  INPUT:

  - `D` – a Python `<dict>`

  - `value` – an object that is value `D`

  - `h` – the hash of the key under which to find `value` in `D`

  The underlying cdef function deletes an item from `D` that is in the hash bucket determined by `h` and whose value is identical with `value`. Of course, this only makes sense if the pairs `(h, value)` corresponding to items in `D` are pair-wise distinct.

  If a matching item cannot be found, the function does nothing and silently returns.