In the optimizer, the following pattern is fairly common:
PyType_Watch(TYPE_WATCHER_ID, type);
_Py_BloomFilter_Add(dependencies, type);
But for immutable, immortal types (which is a lot of the most common types) this is redundant as these types can never change, but increases the number of bits in the bloom filter raising the false positive rate.
The fix is simple: Factor out this pair of calls into a helper function and add a check there:
void watch_type(PyTypeObject *type, _PyBloomFilter *filter) {
if (_Py_IsImmortal(type) && PyType_IsImmutable(type)) {
return;
}
PyType_Watch(TYPE_WATCHER_ID, type);
_Py_BloomFilter_Add(filter, type);
}
Linked PRs
In the optimizer, the following pattern is fairly common:
But for immutable, immortal types (which is a lot of the most common types) this is redundant as these types can never change, but increases the number of bits in the bloom filter raising the false positive rate.
The fix is simple: Factor out this pair of calls into a helper function and add a check there:
Linked PRs