@@ -45,7 +45,6 @@ class loader_life_support {
45
45
loader_life_support *parent = nullptr ;
46
46
std::unordered_set<PyObject *> keep_alive;
47
47
48
- #if defined(PYBIND11_CAN_USE_THREAD_LOCAL)
49
48
struct fake_thread_specific_storage {
50
49
loader_life_support *instance = nullptr ;
51
50
loader_life_support *get () const { return instance; }
@@ -56,24 +55,16 @@ class loader_life_support {
56
55
}
57
56
};
58
57
using loader_storage = fake_thread_specific_storage;
59
- #else
60
- using loader_storage = thread_specific_storage<loader_life_support>;
61
- #endif
62
58
63
59
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
- //
68
60
// Observation: loader_life_support needs to be thread-local, but
69
61
// we don't need to go to extra effort to keep it per-interpreter
70
62
// (i.e., by putting it in internals) since function calls are
71
63
// already isolated to a single interpreter.
64
+ // This saves a significant cost per function call spent in
65
+ // loader_life_support destruction.
72
66
static thread_local fake_thread_specific_storage storage;
73
67
return storage;
74
- #else
75
- return get_internals ().loader_life_support_tls ;
76
- #endif
77
68
}
78
69
79
70
public:
0 commit comments