While doing something else, I ended up reading parts of setobject.c and I noticed that set_intersection doesn't use _PyObject_HashFast():
|
hash = PyObject_Hash(key); |
Is there a reason for it? I tried replacing it (no unit test fails), and benchmarking both versions (with --pgo enabled) but I couldn't see a difference (probably too much noise, or maybe I didn't try hard enough, probably should try on really big big sets to call that operation many a times). In theory though, it should make sets faster when they have strings (and maybe sets of other types slightly slightly slower but _PyObject_HashFast() is used everywhere else in setobject.c so I think that that tradeoff was considered already).
Linked PRs
While doing something else, I ended up reading parts of
setobject.cand I noticed thatset_intersectiondoesn't use_PyObject_HashFast():cpython/Objects/setobject.c
Line 1453 in 2a6888e
Is there a reason for it? I tried replacing it (no unit test fails), and benchmarking both versions (with
--pgoenabled) but I couldn't see a difference (probably too much noise, or maybe I didn't try hard enough, probably should try on really big big sets to call that operation many a times). In theory though, it should makesets faster when they have strings (and maybe sets of other types slightly slightly slower but_PyObject_HashFast()is used everywhere else insetobject.cso I think that that tradeoff was considered already).Linked PRs