If I cythonize the following code:
# cython: language_level=3
cpdef use_dict(dict d, u, v, w):
if u in d:
del d[u]
d.pop(v, None)
d[w] = 1
return [x for x in d if x]
cpdef use_set(set s, u, v, w):
if u in s:
s.remove(u)
s.discard(v)
s.add(w)
return [x for x in s if x]
Then most of use_dict exploits the PyDictconcrete APIs (except for the .pop call which goes through a Python method call), but use_set exploits none of the PySet concrete API except for PySet_Add.
If I cythonize the following code:
Then most of
use_dictexploits thePyDictconcrete APIs (except for the.popcall which goes through a Python method call), butuse_setexploits none of thePySetconcrete API except forPySet_Add.