Class DelFns#
Defined in File pybind11Utils.h
Class Documentation#
-
class DelFns#
Track and access functions to delete via a pair of PyObject*s.
This tracks them in an ordered way, so that execute runs the callbacks in the order they were created.
Public Types
-
using f = std::function<void()>#
Function type.
-
using key = std::pair<PyObject*, std::string>#
The key-type for the delete functions.
Public Functions
-
inline const f &operator[](const key &k) const#
Set the callback function associated with the provided key.
- Parameters:
k – The key associated with the callback function.
- Returns:
f A placeholder for the callback function.
-
inline f &operator[](const key &k)#
Get the callback function associated with the key.
- Parameters:
k – The associated key with the callback function.
- Returns:
f The callback function.
-
inline size_t size()#
Get the number of delete callbacks.
- Returns:
The number of delete callbacks.
-
inline bool contains(const key &k)#
Check whether this key already exists.
- Parameters:
k – The key to check for.
- Returns:
True if this key already exists, false otherwise.
-
inline void execute()#
Execute all the functions in this class.
-
inline void addNonCountingFn(f fn)#
Add a function to DelFns that doesn’t count towards the size of the delete callbacks.
This is useful for things like sync and clear functions, which must do work on the locals dict, but are not actually deleting anything. We don’t want these to count when we get the size, but they do need to run in the proper order when we call execute.
- Parameters:
fn – The function to add.
Public Members
-
size_t strong_ref = 0#
Count the number of references we are actually deleting (not setting to None).
Used in Python 3.13 or greater, since the function frames are optimized.
-
using f = std::function<void()>#