@@ -45,7 +45,6 @@ class loader_life_support {
4545 loader_life_support *parent = nullptr ;
4646 std::unordered_set<PyObject *> keep_alive;
4747
48- #if defined(PYBIND11_CAN_USE_THREAD_LOCAL)
4948 struct fake_thread_specific_storage {
5049 loader_life_support *instance = nullptr ;
5150 loader_life_support *get () const { return instance; }
@@ -56,24 +55,16 @@ class loader_life_support {
5655 }
5756 };
5857 using loader_storage = fake_thread_specific_storage;
59- #else
60- using loader_storage = thread_specific_storage<loader_life_support>;
61- #endif
6258
6359 static loader_storage &get_stack_top () {
64- #if defined(PYBIND11_CAN_USE_THREAD_LOCAL)
65- // Without this branch, loader_life_support destruction is a
66- // significant cost per function call.
67- //
6860 // Observation: loader_life_support needs to be thread-local, but
6961 // we don't need to go to extra effort to keep it per-interpreter
7062 // (i.e., by putting it in internals) since function calls are
7163 // already isolated to a single interpreter.
64+ // This saves a significant cost per function call spent in
65+ // loader_life_support destruction.
7266 static thread_local fake_thread_specific_storage storage;
7367 return storage;
74- #else
75- return get_internals ().loader_life_support_tls ;
76- #endif
7768 }
7869
7970public:
0 commit comments