Skip to content

Commit f6d0f88

Browse files
committed
Simplify PYBIND11_INTERNALS_VERSION >= 12
1 parent d5b8813 commit f6d0f88

File tree

5 files changed

+5
-23
lines changed

5 files changed

+5
-23
lines changed

include/pybind11/detail/class.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,14 +226,12 @@ extern "C" inline void pybind11_meta_dealloc(PyObject *obj) {
226226
local_internals.registered_types_cpp.erase(tinfo->cpptype);
227227
} else {
228228
internals.registered_types_cpp.erase(tindex);
229-
#if PYBIND11_INTERNALS_VERSION >= 12
230229
internals.registered_types_cpp_fast.erase(tinfo->cpptype);
231230
for (const std::type_info *alias : tinfo->alias_chain) {
232231
auto num_erased = internals.registered_types_cpp_fast.erase(alias);
233232
(void) num_erased;
234233
assert(num_erased > 0);
235234
}
236-
#endif
237235
}
238236
internals.registered_types_py.erase(tinfo->type);
239237

include/pybind11/detail/internals.h

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
# define PYBIND11_INTERNALS_VERSION 12
4343
#endif
4444

45-
#if PYBIND11_INTERNALS_VERSION < 11
46-
# error "PYBIND11_INTERNALS_VERSION 11 is the minimum for all platforms for pybind11v3."
45+
#if PYBIND11_INTERNALS_VERSION < 12
46+
# error "PYBIND11_INTERNALS_VERSION 12 is the minimum for all platforms for pybind11v3."
4747
#endif
4848

4949
PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
@@ -273,14 +273,12 @@ struct internals {
273273
pymutex mutex;
274274
pymutex exception_translator_mutex;
275275
#endif
276-
#if PYBIND11_INTERNALS_VERSION >= 12
277276
// non-normative but fast "hint" for registered_types_cpp. Meant
278277
// to be used as the first level of a two-level lookup: successful
279278
// lookups are correct, but unsuccessful lookups need to try
280279
// registered_types_cpp and then backfill this map if they find
281280
// anything.
282281
fast_type_map<type_info *> registered_types_cpp_fast;
283-
#endif
284282

285283
// std::type_index -> pybind11's type information
286284
type_map<type_info *> registered_types_cpp;
@@ -306,9 +304,6 @@ struct internals {
306304
PyObject *instance_base = nullptr;
307305
// Unused if PYBIND11_SIMPLE_GIL_MANAGEMENT is defined:
308306
thread_specific_storage<PyThreadState> tstate;
309-
#if PYBIND11_INTERNALS_VERSION <= 11
310-
thread_specific_storage<loader_life_support> loader_life_support_tls; // OBSOLETE (PR #5830)
311-
#endif
312307
// Unused if PYBIND11_SIMPLE_GIL_MANAGEMENT is defined:
313308
PyInterpreterState *istate = nullptr;
314309

@@ -396,7 +391,6 @@ struct type_info {
396391
void *(*module_local_load)(PyObject *, const type_info *) = nullptr;
397392
holder_enum_t holder_enum_v = holder_enum_t::undefined;
398393

399-
#if PYBIND11_INTERNALS_VERSION >= 12
400394
// When a type appears in multiple DSOs,
401395
// internals::registered_types_cpp_fast will have multiple distinct
402396
// keys (the std::type_info from each DSO) mapped to the same
@@ -407,7 +401,6 @@ struct type_info {
407401
// nb_alias_chain` added in
408402
// https://github.com/wjakob/nanobind/commit/b515b1f7f2f4ecc0357818e6201c94a9f4cbfdc2
409403
std::forward_list<const std::type_info *> alias_chain;
410-
#endif
411404

412405
/* A simple type never occurs as a (direct or indirect) parent
413406
* of a class that makes use of multiple inheritance.

include/pybind11/detail/type_caster_base.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -227,32 +227,26 @@ inline detail::type_info *get_global_type_info_lock_held(const std::type_info &t
227227
// next time.
228228
detail::type_info *type_info = nullptr;
229229
auto &internals = get_internals();
230-
#if PYBIND11_INTERNALS_VERSION >= 12
231230
auto &fast_types = internals.registered_types_cpp_fast;
232-
#endif
233231
auto &types = internals.registered_types_cpp;
234-
#if PYBIND11_INTERNALS_VERSION >= 12
235232
auto fast_it = fast_types.find(&tp);
236233
if (fast_it != fast_types.end()) {
237-
# ifndef NDEBUG
234+
#ifndef NDEBUG
238235
auto types_it = types.find(std::type_index(tp));
239236
assert(types_it != types.end());
240237
assert(types_it->second == fast_it->second);
241-
# endif
238+
#endif
242239
return fast_it->second;
243240
}
244-
#endif // PYBIND11_INTERNALS_VERSION >= 12
245241

246242
auto it = types.find(std::type_index(tp));
247243
if (it != types.end()) {
248-
#if PYBIND11_INTERNALS_VERSION >= 12
249244
// We found the type in the slow map but not the fast one, so
250245
// some other DSO added it (otherwise it would be in the fast
251246
// map under &tp) and therefore we must be an alias. Record
252247
// that.
253248
it->second->alias_chain.push_front(&tp);
254249
fast_types.emplace(&tp, it->second);
255-
#endif
256250
type_info = it->second;
257251
}
258252
return type_info;

include/pybind11/gil_safe_call_once.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,4 +196,5 @@ class gil_safe_call_once_and_store {
196196
atomic_bool is_initialized_by_atleast_one_interpreter_{false};
197197
};
198198
#endif
199+
199200
PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)

include/pybind11/pybind11.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1692,9 +1692,7 @@ class generic_type : public object {
16921692
local_internals.registered_types_cpp[rec.type] = tinfo;
16931693
} else {
16941694
internals.registered_types_cpp[tindex] = tinfo;
1695-
#if PYBIND11_INTERNALS_VERSION >= 12
16961695
internals.registered_types_cpp_fast[rec.type] = tinfo;
1697-
#endif
16981696
}
16991697

17001698
PYBIND11_WARNING_PUSH
@@ -2201,9 +2199,7 @@ class class_ : public detail::generic_type {
22012199
type_info *const val
22022200
= internals.registered_types_cpp[std::type_index(typeid(type))];
22032201
internals.registered_types_cpp[std::type_index(typeid(type_alias))] = val;
2204-
#if PYBIND11_INTERNALS_VERSION >= 12
22052202
internals.registered_types_cpp_fast[&typeid(type_alias)] = val;
2206-
#endif
22072203
}
22082204
});
22092205
}

0 commit comments

Comments
 (0)