internals.h
Go to the documentation of this file.
1 /*
2  pybind11/detail/internals.h: Internal data structure and related functions
3 
4  Copyright (c) 2017 Wenzel Jakob <wenzel.jakob@epfl.ch>
5 
6  All rights reserved. Use of this source code is governed by a
7  BSD-style license that can be found in the LICENSE file.
8 */
9 
10 #pragma once
11 
12 #include "../pytypes.h"
13 
14 #include <exception>
15 
30 #ifndef PYBIND11_INTERNALS_VERSION
31 # define PYBIND11_INTERNALS_VERSION 4
32 #endif
33 
35 
36 using ExceptionTranslator = void (*)(std::exception_ptr);
37 
39 
40 // Forward declarations
41 inline PyTypeObject *make_static_property_type();
42 inline PyTypeObject *make_default_metaclass();
43 inline PyObject *make_object_base_type(PyTypeObject *metaclass);
44 
45 // The old Python Thread Local Storage (TLS) API is deprecated in Python 3.7 in favor of the new
46 // Thread Specific Storage (TSS) API.
47 #if PY_VERSION_HEX >= 0x03070000
48 // Avoid unnecessary allocation of `Py_tss_t`, since we cannot use
49 // `Py_LIMITED_API` anyway.
50 # if PYBIND11_INTERNALS_VERSION > 4
51 # define PYBIND11_TLS_KEY_REF Py_tss_t &
52 # ifdef __GNUC__
53 // Clang on macOS warns due to `Py_tss_NEEDS_INIT` not specifying an initializer
54 // for every field.
55 # define PYBIND11_TLS_KEY_INIT(var) \
56  _Pragma("GCC diagnostic push") \
57  _Pragma("GCC diagnostic ignored \"-Wmissing-field-initializers\"") \
58  Py_tss_t var \
59  = Py_tss_NEEDS_INIT; \
60  _Pragma("GCC diagnostic pop")
61 # else
62 # define PYBIND11_TLS_KEY_INIT(var) Py_tss_t var = Py_tss_NEEDS_INIT;
63 # endif
64 # define PYBIND11_TLS_KEY_CREATE(var) (PyThread_tss_create(&(var)) == 0)
65 # define PYBIND11_TLS_GET_VALUE(key) PyThread_tss_get(&(key))
66 # define PYBIND11_TLS_REPLACE_VALUE(key, value) PyThread_tss_set(&(key), (value))
67 # define PYBIND11_TLS_DELETE_VALUE(key) PyThread_tss_set(&(key), nullptr)
68 # define PYBIND11_TLS_FREE(key) PyThread_tss_delete(&(key))
69 # else
70 # define PYBIND11_TLS_KEY_REF Py_tss_t *
71 # define PYBIND11_TLS_KEY_INIT(var) Py_tss_t *var = nullptr;
72 # define PYBIND11_TLS_KEY_CREATE(var) \
73  (((var) = PyThread_tss_alloc()) != nullptr && (PyThread_tss_create((var)) == 0))
74 # define PYBIND11_TLS_GET_VALUE(key) PyThread_tss_get((key))
75 # define PYBIND11_TLS_REPLACE_VALUE(key, value) PyThread_tss_set((key), (value))
76 # define PYBIND11_TLS_DELETE_VALUE(key) PyThread_tss_set((key), nullptr)
77 # define PYBIND11_TLS_FREE(key) PyThread_tss_free(key)
78 # endif
79 #else
80 // Usually an int but a long on Cygwin64 with Python 3.x
81 # define PYBIND11_TLS_KEY_REF decltype(PyThread_create_key())
82 # define PYBIND11_TLS_KEY_INIT(var) PYBIND11_TLS_KEY_REF var = 0;
83 # define PYBIND11_TLS_KEY_CREATE(var) (((var) = PyThread_create_key()) != -1)
84 # define PYBIND11_TLS_GET_VALUE(key) PyThread_get_key_value((key))
85 # if defined(PYPY_VERSION)
86 // On CPython < 3.4 and on PyPy, `PyThread_set_key_value` strangely does not set
87 // the value if it has already been set. Instead, it must first be deleted and
88 // then set again.
89 inline void tls_replace_value(PYBIND11_TLS_KEY_REF key, void *value) {
90  PyThread_delete_key_value(key);
91  PyThread_set_key_value(key, value);
92 }
93 # define PYBIND11_TLS_DELETE_VALUE(key) PyThread_delete_key_value(key)
94 # define PYBIND11_TLS_REPLACE_VALUE(key, value) \
95  ::pybind11::detail::tls_replace_value((key), (value))
96 # else
97 # define PYBIND11_TLS_DELETE_VALUE(key) PyThread_set_key_value((key), nullptr)
98 # define PYBIND11_TLS_REPLACE_VALUE(key, value) PyThread_set_key_value((key), (value))
99 # endif
100 # define PYBIND11_TLS_FREE(key) (void) key
101 #endif
102 
103 // Python loads modules by default with dlopen with the RTLD_LOCAL flag; under libc++ and possibly
104 // other STLs, this means `typeid(A)` from one module won't equal `typeid(A)` from another module
105 // even when `A` is the same, non-hidden-visibility type (e.g. from a common include). Under
106 // libstdc++, this doesn't happen: equality and the type_index hash are based on the type name,
107 // which works. If not under a known-good stl, provide our own name-based hash and equality
108 // functions that use the type name.
109 #if defined(__GLIBCXX__)
110 inline bool same_type(const std::type_info &lhs, const std::type_info &rhs) { return lhs == rhs; }
111 using type_hash = std::hash<std::type_index>;
112 using type_equal_to = std::equal_to<std::type_index>;
113 #else
114 inline bool same_type(const std::type_info &lhs, const std::type_info &rhs) {
115  return lhs.name() == rhs.name() || std::strcmp(lhs.name(), rhs.name()) == 0;
116 }
117 
118 struct type_hash {
119  size_t operator()(const std::type_index &t) const {
120  size_t hash = 5381;
121  const char *ptr = t.name();
122  while (auto c = static_cast<unsigned char>(*ptr++)) {
123  hash = (hash * 33) ^ c;
124  }
125  return hash;
126  }
127 };
128 
130  bool operator()(const std::type_index &lhs, const std::type_index &rhs) const {
131  return lhs.name() == rhs.name() || std::strcmp(lhs.name(), rhs.name()) == 0;
132  }
133 };
134 #endif
135 
136 template <typename value_type>
137 using type_map = std::unordered_map<std::type_index, value_type, type_hash, type_equal_to>;
138 
140  inline size_t operator()(const std::pair<const PyObject *, const char *> &v) const {
141  size_t value = std::hash<const void *>()(v.first);
142  value ^= std::hash<const void *>()(v.second) + 0x9e3779b9 + (value << 6) + (value >> 2);
143  return value;
144  }
145 };
146 
150 struct internals {
151  // std::type_index -> pybind11's type information
153  // PyTypeObject* -> base type_info(s)
154  std::unordered_map<PyTypeObject *, std::vector<type_info *>> registered_types_py;
155  std::unordered_multimap<const void *, instance *> registered_instances; // void * -> instance*
156  std::unordered_set<std::pair<const PyObject *, const char *>, override_hash>
159  std::unordered_map<const PyObject *, std::vector<PyObject *>> patients;
160  std::forward_list<ExceptionTranslator> registered_exception_translators;
161  std::unordered_map<std::string, void *> shared_data; // Custom data to be shared across
162  // extensions
163 #if PYBIND11_INTERNALS_VERSION == 4
165 #endif
166  std::forward_list<std::string> static_strings; // Stores the std::strings backing
167  // detail::c_str()
168  PyTypeObject *static_property_type;
169  PyTypeObject *default_metaclass;
170  PyObject *instance_base;
171 #if defined(WITH_THREAD)
172  PYBIND11_TLS_KEY_INIT(tstate)
173 # if PYBIND11_INTERNALS_VERSION > 4
174  PYBIND11_TLS_KEY_INIT(loader_life_support_tls_key)
175 # endif // PYBIND11_INTERNALS_VERSION > 4
176  PyInterpreterState *istate = nullptr;
177  ~internals() {
178 # if PYBIND11_INTERNALS_VERSION > 4
179  PYBIND11_TLS_FREE(loader_life_support_tls_key);
180 # endif // PYBIND11_INTERNALS_VERSION > 4
181 
182  // This destructor is called *after* Py_Finalize() in finalize_interpreter().
183  // That *SHOULD BE* fine. The following details what happens when PyThread_tss_free is
184  // called. PYBIND11_TLS_FREE is PyThread_tss_free on python 3.7+. On older python, it does
185  // nothing. PyThread_tss_free calls PyThread_tss_delete and PyMem_RawFree.
186  // PyThread_tss_delete just calls TlsFree (on Windows) or pthread_key_delete (on *NIX).
187  // Neither of those have anything to do with CPython internals. PyMem_RawFree *requires*
188  // that the `tstate` be allocated with the CPython allocator.
189  PYBIND11_TLS_FREE(tstate);
190  }
191 #endif
192 };
193 
196 struct type_info {
197  PyTypeObject *type;
198  const std::type_info *cpptype;
199  size_t type_size, type_align, holder_size_in_ptrs;
200  void *(*operator_new)(size_t);
201  void (*init_instance)(instance *, const void *);
202  void (*dealloc)(value_and_holder &v_h);
203  std::vector<PyObject *(*) (PyObject *, PyTypeObject *)> implicit_conversions;
204  std::vector<std::pair<const std::type_info *, void *(*) (void *)>> implicit_casts;
205  std::vector<bool (*)(PyObject *, void *&)> *direct_conversions;
206  buffer_info *(*get_buffer)(PyObject *, void *) = nullptr;
207  void *get_buffer_data = nullptr;
208  void *(*module_local_load)(PyObject *, const type_info *) = nullptr;
209  /* A simple type never occurs as a (direct or indirect) parent
210  * of a class that makes use of multiple inheritance.
211  * A type can be simple even if it has non-simple ancestors as long as it has no descendants.
212  */
213  bool simple_type : 1;
214  /* True if there is no multiple inheritance in this type's inheritance tree */
216  /* for base vs derived holder_type checks */
217  bool default_holder : 1;
218  /* true if this is a type registered with py::module_local */
219  bool module_local : 1;
220 };
221 
223 #if defined(_MSC_VER) && defined(_DEBUG)
224 # define PYBIND11_BUILD_TYPE "_debug"
225 #else
226 # define PYBIND11_BUILD_TYPE ""
227 #endif
228 
232 #ifndef PYBIND11_COMPILER_TYPE
233 # if defined(_MSC_VER)
234 # define PYBIND11_COMPILER_TYPE "_msvc"
235 # elif defined(__INTEL_COMPILER)
236 # define PYBIND11_COMPILER_TYPE "_icc"
237 # elif defined(__clang__)
238 # define PYBIND11_COMPILER_TYPE "_clang"
239 # elif defined(__PGI)
240 # define PYBIND11_COMPILER_TYPE "_pgi"
241 # elif defined(__MINGW32__)
242 # define PYBIND11_COMPILER_TYPE "_mingw"
243 # elif defined(__CYGWIN__)
244 # define PYBIND11_COMPILER_TYPE "_gcc_cygwin"
245 # elif defined(__GNUC__)
246 # define PYBIND11_COMPILER_TYPE "_gcc"
247 # else
248 # define PYBIND11_COMPILER_TYPE "_unknown"
249 # endif
250 #endif
251 
253 #ifndef PYBIND11_STDLIB
254 # if defined(_LIBCPP_VERSION)
255 # define PYBIND11_STDLIB "_libcpp"
256 # elif defined(__GLIBCXX__) || defined(__GLIBCPP__)
257 # define PYBIND11_STDLIB "_libstdcpp"
258 # else
259 # define PYBIND11_STDLIB ""
260 # endif
261 #endif
262 
264 #ifndef PYBIND11_BUILD_ABI
265 # if defined(__GXX_ABI_VERSION)
266 # define PYBIND11_BUILD_ABI "_cxxabi" PYBIND11_TOSTRING(__GXX_ABI_VERSION)
267 # else
268 # define PYBIND11_BUILD_ABI ""
269 # endif
270 #endif
271 
272 #ifndef PYBIND11_INTERNALS_KIND
273 # if defined(WITH_THREAD)
274 # define PYBIND11_INTERNALS_KIND ""
275 # else
276 # define PYBIND11_INTERNALS_KIND "_without_thread"
277 # endif
278 #endif
279 
280 #define PYBIND11_INTERNALS_ID \
281  "__pybind11_internals_v" PYBIND11_TOSTRING(PYBIND11_INTERNALS_VERSION) \
282  PYBIND11_INTERNALS_KIND PYBIND11_COMPILER_TYPE PYBIND11_STDLIB PYBIND11_BUILD_ABI \
283  PYBIND11_BUILD_TYPE "__"
284 
285 #define PYBIND11_MODULE_LOCAL_ID \
286  "__pybind11_module_local_v" PYBIND11_TOSTRING(PYBIND11_INTERNALS_VERSION) \
287  PYBIND11_INTERNALS_KIND PYBIND11_COMPILER_TYPE PYBIND11_STDLIB PYBIND11_BUILD_ABI \
288  PYBIND11_BUILD_TYPE "__"
289 
293  static internals **internals_pp = nullptr;
294  return internals_pp;
295 }
296 
297 // forward decl
298 inline void translate_exception(std::exception_ptr);
299 
300 template <class T,
302 bool handle_nested_exception(const T &exc, const std::exception_ptr &p) {
303  std::exception_ptr nested = exc.nested_ptr();
304  if (nested != nullptr && nested != p) {
305  translate_exception(nested);
306  return true;
307  }
308  return false;
309 }
310 
311 template <class T,
313 bool handle_nested_exception(const T &exc, const std::exception_ptr &p) {
314  if (const auto *nep = dynamic_cast<const std::nested_exception *>(std::addressof(exc))) {
315  return handle_nested_exception(*nep, p);
316  }
317  return false;
318 }
319 
320 inline bool raise_err(PyObject *exc_type, const char *msg) {
321  if (PyErr_Occurred()) {
322  raise_from(exc_type, msg);
323  return true;
324  }
325  PyErr_SetString(exc_type, msg);
326  return false;
327 }
328 
329 inline void translate_exception(std::exception_ptr p) {
330  if (!p) {
331  return;
332  }
333  try {
334  std::rethrow_exception(p);
335  } catch (error_already_set &e) {
337  e.restore();
338  return;
339  } catch (const builtin_exception &e) {
340  // Could not use template since it's an abstract class.
341  if (const auto *nep = dynamic_cast<const std::nested_exception *>(std::addressof(e))) {
342  handle_nested_exception(*nep, p);
343  }
344  e.set_error();
345  return;
346  } catch (const std::bad_alloc &e) {
348  raise_err(PyExc_MemoryError, e.what());
349  return;
350  } catch (const std::domain_error &e) {
352  raise_err(PyExc_ValueError, e.what());
353  return;
354  } catch (const std::invalid_argument &e) {
356  raise_err(PyExc_ValueError, e.what());
357  return;
358  } catch (const std::length_error &e) {
360  raise_err(PyExc_ValueError, e.what());
361  return;
362  } catch (const std::out_of_range &e) {
364  raise_err(PyExc_IndexError, e.what());
365  return;
366  } catch (const std::range_error &e) {
368  raise_err(PyExc_ValueError, e.what());
369  return;
370  } catch (const std::overflow_error &e) {
372  raise_err(PyExc_OverflowError, e.what());
373  return;
374  } catch (const std::exception &e) {
376  raise_err(PyExc_RuntimeError, e.what());
377  return;
378  } catch (const std::nested_exception &e) {
380  raise_err(PyExc_RuntimeError, "Caught an unknown nested exception!");
381  return;
382  } catch (...) {
383  raise_err(PyExc_RuntimeError, "Caught an unknown exception!");
384  return;
385  }
386 }
387 
388 #if !defined(__GLIBCXX__)
389 inline void translate_local_exception(std::exception_ptr p) {
390  try {
391  if (p) {
392  std::rethrow_exception(p);
393  }
394  } catch (error_already_set &e) {
395  e.restore();
396  return;
397  } catch (const builtin_exception &e) {
398  e.set_error();
399  return;
400  }
401 }
402 #endif
403 
406  auto **&internals_pp = get_internals_pp();
407  if (internals_pp && *internals_pp) {
408  return **internals_pp;
409  }
410 
411  // Ensure that the GIL is held since we will need to make Python calls.
412  // Cannot use py::gil_scoped_acquire here since that constructor calls get_internals.
413  struct gil_scoped_acquire_local {
414  gil_scoped_acquire_local() : state(PyGILState_Ensure()) {}
415  ~gil_scoped_acquire_local() { PyGILState_Release(state); }
416  const PyGILState_STATE state;
417  } gil;
418  error_scope err_scope;
419 
421  auto builtins = handle(PyEval_GetBuiltins());
422  if (builtins.contains(id) && isinstance<capsule>(builtins[id])) {
423  internals_pp = static_cast<internals **>(capsule(builtins[id]));
424 
425  // We loaded builtins through python's builtins, which means that our `error_already_set`
426  // and `builtin_exception` may be different local classes than the ones set up in the
427  // initial exception translator, below, so add another for our local exception classes.
428  //
429  // libstdc++ doesn't require this (types there are identified only by name)
430  // libc++ with CPython doesn't require this (types are explicitly exported)
431  // libc++ with PyPy still need it, awaiting further investigation
432 #if !defined(__GLIBCXX__)
433  (*internals_pp)->registered_exception_translators.push_front(&translate_local_exception);
434 #endif
435  } else {
436  if (!internals_pp) {
437  internals_pp = new internals *();
438  }
439  auto *&internals_ptr = *internals_pp;
440  internals_ptr = new internals();
441 #if defined(WITH_THREAD)
442 
443 # if PY_VERSION_HEX < 0x03090000
444  PyEval_InitThreads();
445 # endif
446  PyThreadState *tstate = PyThreadState_Get();
447  if (!PYBIND11_TLS_KEY_CREATE(internals_ptr->tstate)) {
448  pybind11_fail("get_internals: could not successfully initialize the tstate TSS key!");
449  }
450  PYBIND11_TLS_REPLACE_VALUE(internals_ptr->tstate, tstate);
451 
452 # if PYBIND11_INTERNALS_VERSION > 4
453  if (!PYBIND11_TLS_KEY_CREATE(internals_ptr->loader_life_support_tls_key)) {
454  pybind11_fail("get_internals: could not successfully initialize the "
455  "loader_life_support TSS key!");
456  }
457 # endif
458  internals_ptr->istate = tstate->interp;
459 #endif
460  builtins[id] = capsule(internals_pp);
461  internals_ptr->registered_exception_translators.push_front(&translate_exception);
463  internals_ptr->default_metaclass = make_default_metaclass();
464  internals_ptr->instance_base = make_object_base_type(internals_ptr->default_metaclass);
465  }
466  return **internals_pp;
467 }
468 
469 // the internals struct (above) is shared between all the modules. local_internals are only
470 // for a single module. Any changes made to internals may require an update to
471 // PYBIND11_INTERNALS_VERSION, breaking backwards compatibility. local_internals is, by design,
472 // restricted to a single module. Whether a module has local internals or not should not
473 // impact any other modules, because the only things accessing the local internals is the
474 // module that contains them.
477  std::forward_list<ExceptionTranslator> registered_exception_translators;
478 #if defined(WITH_THREAD) && PYBIND11_INTERNALS_VERSION == 4
479 
480  // For ABI compatibility, we can't store the loader_life_support TLS key in
481  // the `internals` struct directly. Instead, we store it in `shared_data` and
482  // cache a copy in `local_internals`. If we allocated a separate TLS key for
483  // each instance of `local_internals`, we could end up allocating hundreds of
484  // TLS keys if hundreds of different pybind11 modules are loaded (which is a
485  // plausible number).
486  PYBIND11_TLS_KEY_INIT(loader_life_support_tls_key)
487 
488  // Holds the shared TLS key for the loader_life_support stack.
489  struct shared_loader_life_support_data {
490  PYBIND11_TLS_KEY_INIT(loader_life_support_tls_key)
491  shared_loader_life_support_data() {
492  if (!PYBIND11_TLS_KEY_CREATE(loader_life_support_tls_key)) {
493  pybind11_fail("local_internals: could not successfully initialize the "
494  "loader_life_support TLS key!");
495  }
496  }
497  // We can't help but leak the TLS key, because Python never unloads extension modules.
498  };
499 
500  local_internals() {
501  auto &internals = get_internals();
502  // Get or create the `loader_life_support_stack_key`.
503  auto &ptr = internals.shared_data["_life_support"];
504  if (!ptr) {
505  ptr = new shared_loader_life_support_data;
506  }
507  loader_life_support_tls_key
508  = static_cast<shared_loader_life_support_data *>(ptr)->loader_life_support_tls_key;
509  }
510 #endif // defined(WITH_THREAD) && PYBIND11_INTERNALS_VERSION == 4
511 };
512 
515  static local_internals locals;
516  return locals;
517 }
518 
523 template <typename... Args>
524 const char *c_str(Args &&...args) {
525  auto &strings = get_internals().static_strings;
526  strings.emplace_front(std::forward<Args>(args)...);
527  return strings.front().c_str();
528 }
529 
531 
532 PYBIND11_NOINLINE void *get_shared_data(const std::string &name) {
537  auto it = internals.shared_data.find(name);
538  return it != internals.shared_data.end() ? it->second : nullptr;
539 }
540 
542 PYBIND11_NOINLINE void *set_shared_data(const std::string &name, void *data) {
544  return data;
545 }
546 
550 template <typename T>
551 T &get_or_create_shared_data(const std::string &name) {
553  auto it = internals.shared_data.find(name);
554  T *ptr = (T *) (it != internals.shared_data.end() ? it->second : nullptr);
555  if (!ptr) {
556  ptr = new T();
557  internals.shared_data[name] = ptr;
558  }
559  return *ptr;
560 }
561 
const gtsam::Symbol key('X', 0)
ssize_t hash(handle obj)
Definition: pytypes.h:792
void(*)(std::exception_ptr) ExceptionTranslator
Definition: internals.h:36
PYBIND11_NOINLINE void * set_shared_data(const std::string &name, void *data)
Set the shared data that can be later recovered by get_shared_data().
Definition: internals.h:542
size_t type_size
Definition: internals.h:199
virtual void set_error() const =0
Set the error using the Python C API.
T & get_or_create_shared_data(const std::string &name)
Definition: internals.h:551
std::forward_list< ExceptionTranslator > registered_exception_translators
Definition: internals.h:160
Annotation which requests that a special metaclass is created for a type.
Definition: attr.h:82
void restore()
Definition: pytypes.h:612
bool simple_type
Definition: internals.h:213
bool default_holder
Definition: internals.h:217
Definition: pytypes.h:2012
PyTypeObject * make_default_metaclass()
Definition: class.h:241
PyObject * instance_base
Definition: internals.h:170
PYBIND11_NOINLINE internals & get_internals()
Return a reference to the current internals data.
Definition: internals.h:405
PyTypeObject * make_static_property_type()
Definition: class.h:61
Scalar Scalar * c
Definition: benchVecAdd.cpp:17
type_map< type_info * > registered_types_cpp
Definition: internals.h:152
PyObject * make_object_base_type(PyTypeObject *metaclass)
Definition: class.h:463
bool handle_nested_exception(const T &exc, const std::exception_ptr &p)
Definition: internals.h:302
void raise_from(PyObject *type, const char *message)
Definition: pytypes.h:655
std::forward_list< ExceptionTranslator > registered_exception_translators
Definition: internals.h:477
Definition: BFloat16.h:88
PyTypeObject * type
Definition: internals.h:197
std::vector< std::pair< const std::type_info *, void *(*)(void *)> > implicit_casts
Definition: internals.h:204
bool operator()(const std::type_index &lhs, const std::type_index &rhs) const
Definition: internals.h:130
std::unordered_multimap< const void *, instance * > registered_instances
Definition: internals.h:155
#define PYBIND11_TLS_FREE(key)
Definition: internals.h:100
The &#39;instance&#39; type which needs to be standard layout (need to be able to use &#39;offsetof&#39;) ...
static const Similarity3 id
std::vector< PyObject * > unused_loader_patient_stack_remove_at_v5
Definition: internals.h:164
const char * c_str(Args &&...args)
Definition: internals.h:524
bool same_type(const std::type_info &lhs, const std::type_info &rhs)
Definition: internals.h:114
PyExc_RuntimeError [[noreturn]] PYBIND11_NOINLINE void pybind11_fail(const char *reason)
Used internally.
PYBIND11_NOINLINE void * get_shared_data(const std::string &name)
Definition: internals.h:535
PyTypeObject * static_property_type
Definition: internals.h:168
const std::type_info * cpptype
Definition: internals.h:198
#define PYBIND11_TLS_KEY_REF
Definition: internals.h:81
size_t operator()(const std::pair< const PyObject *, const char *> &v) const
Definition: internals.h:140
std::unordered_set< std::pair< const PyObject *, const char * >, override_hash > inactive_override_cache
Definition: internals.h:157
type_map< std::vector< bool(*)(PyObject *, void *&)> > direct_conversions
Definition: internals.h:158
Array< int, Dynamic, 1 > v
local_internals & get_local_internals()
Works like get_internals, but for things which are locally registered.
Definition: internals.h:514
type_map< type_info * > registered_types_cpp
Definition: internals.h:476
Eigen::Triplet< double > T
int data[]
Array< double, 1, 3 > e(1./3., 0.5, 2.)
std::vector< bool(*)(PyObject *, void *&)> * direct_conversions
Definition: internals.h:205
PyTypeObject * default_metaclass
Definition: internals.h:169
#define PYBIND11_TLS_KEY_INIT(var)
Definition: internals.h:82
#define PYBIND11_INTERNALS_ID
Definition: internals.h:280
void translate_exception(std::exception_ptr)
Definition: internals.h:329
std::forward_list< std::string > static_strings
Definition: internals.h:166
bool simple_ancestors
Definition: internals.h:215
#define PYBIND11_TLS_REPLACE_VALUE(key, value)
Definition: internals.h:98
RAII wrapper that temporarily clears any Python error state.
float * p
std::unordered_map< const PyObject *, std::vector< PyObject * > > patients
Definition: internals.h:159
std::unordered_map< std::type_index, value_type, type_hash, type_equal_to > type_map
Definition: internals.h:137
C++ bindings of builtin Python exceptions.
typename std::enable_if< B, T >::type enable_if_t
from cpp_future import (convenient aliases from C++14/17)
bool raise_err(PyObject *exc_type, const char *msg)
Definition: internals.h:320
void translate_local_exception(std::exception_ptr p)
Definition: internals.h:389
Annotation for function names.
Definition: attr.h:48
Information record describing a Python buffer object.
Definition: buffer_info.h:43
std::unordered_map< std::string, void * > shared_data
Definition: internals.h:161
std::unordered_map< PyTypeObject *, std::vector< type_info * > > registered_types_py
Definition: internals.h:154
internals **& get_internals_pp()
Definition: internals.h:292
size_t operator()(const std::type_index &t) const
Definition: internals.h:119
std::vector< PyObject *(*)(PyObject *, PyTypeObject *)> implicit_conversions
Definition: internals.h:203
#define PYBIND11_NAMESPACE_END(name)
bool module_local
Definition: internals.h:219
Point2 t(10, 10)
#define PYBIND11_NAMESPACE_BEGIN(name)
#define PYBIND11_TLS_KEY_CREATE(var)
Definition: internals.h:83


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:34:23