μHAL (v2.8.17)
Part of the IPbus software repository
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Functions
const_name

Unless stated otherwise, the following C++ functions behave the same as their Python counterparts. More...

Functions

dict globals ()
 Return a dictionary representing the global variables in the current execution frame, or __main__.__dict__ if there is no frame (usually when the interpreter is embedded). More...
 
template<typename T , detail::enable_if_t< std::is_base_of< object, T >::value, int > = 0>
bool isinstance (handle obj)
 \rst Return true if obj is an instance of T. More...
 
bool isinstance (handle obj, handle type)
 Return true if obj is an instance of the type. More...
 
bool hasattr (handle obj, handle name)
 
bool hasattr (handle obj, const char *name)
 
void delattr (handle obj, handle name)
 
void delattr (handle obj, const char *name)
 
object getattr (handle obj, handle name)
 
object getattr (handle obj, const char *name)
 
object getattr (handle obj, handle name, handle default_)
 
object getattr (handle obj, const char *name, handle default_)
 
void setattr (handle obj, handle name, handle value)
 
void setattr (handle obj, const char *name, handle value)
 
ssize_t hash (handle obj)
 
size_t len (handle h)
 Get the length of a Python object. More...
 
size_t len_hint (handle h)
 Get the length hint of a Python object. More...
 
str repr (handle h)
 
iterator iter (handle obj)
 

Detailed Description

Unless stated otherwise, the following C++ functions behave the same as their Python counterparts.

Function Documentation

◆ delattr() [1/2]

void delattr ( handle  obj,
const char *  name 
)
inline

Definition at line 531 of file pytypes.h.

References handle::ptr().

◆ delattr() [2/2]

void delattr ( handle  obj,
handle  name 
)
inline

Definition at line 525 of file pytypes.h.

References handle::ptr().

◆ getattr() [1/4]

object getattr ( handle  obj,
const char *  name 
)
inline

Definition at line 545 of file pytypes.h.

References handle::ptr().

◆ getattr() [2/4]

object getattr ( handle  obj,
const char *  name,
handle  default_ 
)
inline

Definition at line 561 of file pytypes.h.

References handle::ptr().

◆ getattr() [3/4]

object getattr ( handle  obj,
handle  name 
)
inline

◆ getattr() [4/4]

object getattr ( handle  obj,
handle  name,
handle  default_ 
)
inline

Definition at line 553 of file pytypes.h.

References handle::ptr().

◆ globals()

dict globals ( )
inline

Return a dictionary representing the global variables in the current execution frame, or __main__.__dict__ if there is no frame (usually when the interpreter is embedded).

Definition at line 1288 of file pybind11.h.

References module_::import().

Referenced by ConstructorStats::gc().

◆ hasattr() [1/2]

bool hasattr ( handle  obj,
const char *  name 
)
inline

Definition at line 521 of file pytypes.h.

References handle::ptr().

◆ hasattr() [2/2]

bool hasattr ( handle  obj,
handle  name 
)
inline

Definition at line 517 of file pytypes.h.

References handle::ptr().

Referenced by conftest.SanitizedString::__eq__(), module_::add_object(), pybind11.setup_helpers.build_ext::build_extensions(), exception< type >::exception(), test_custom_type_setup::gc_tester(), test_exceptions::ignore_pytest_unraisable_warning(), generic_type::initialize(), cpp_function::initialize_generic(), type_caster< T, enable_if_t< std::is_arithmetic< T >::value &&!is_std_char_type< T >::value > >::load(), type_caster< bool >::load(), make_new_python_type(), accessor< Policy >::PYBIND11_DEPRECATED(), conftest::pytest_assertrepr_compare(), test_pytypes::test_accessor_moves(), test_virtual_functions::test_alias_delay_initialization2(), test_class::test_aligned(), test_files::test_build_global_dist(), test_files::test_build_sdist(), test_modules::test_builtin_key_type(), test_builtin_casters::test_bytearray_to_string(), test_call_policies::test_call_guard(), test_local_bindings::test_duplicate_local(), test_methods_and_attributes::test_dynamic_attributes(), test_pytypes::test_isinstance_string_types(), test_local_bindings::test_local_bindings(), test_stl::test_optional(), test_pytypes::test_pass_bytes_or_unicode_to_string_types(), test_pytypes::test_pybind11_str_raw_str(), test_exceptions::test_python_alreadyset_in_destructor(), test_eigen_tensor::test_reference_internal(), test_pytypes::test_simple_namespace(), test_builtin_casters::test_single_char_arguments(), test_methods_and_attributes::test_static_properties(), test_pytypes::test_str(), test_builtin_casters::test_string_view(), test_pytypes::test_unhashable_exceptions(), test_builtin_casters::test_unicode_conversion(), and type_caster_generic::try_load_foreign_module_local().

◆ hash()

ssize_t hash ( handle  obj)
inline

◆ isinstance() [1/2]

template<typename T , detail::enable_if_t< std::is_base_of< object, T >::value, int > = 0>
bool isinstance ( handle  obj)

\rst Return true if obj is an instance of T.

Type T must be a subclass of object or a class which was exposed to Python as py::class_<T>. \endrst

Definition at line 489 of file pytypes.h.

Referenced by uhal::_add_int_method_to_ValWord(), isinstance_generic(), type_caster< Type, enable_if_t< is_eigen_dense_plain< Type >::value > >::load(), test_pytypes::test_accessor_moves(), test_numpy_vectorize::test_array_collapse(), test_builtin_casters::test_bytes_to_string(), test_chrono::test_chrono_duration_roundtrip(), test_chrono::test_chrono_steady_clock(), test_chrono::test_chrono_steady_clock_roundtrip(), test_chrono::test_chrono_system_clock(), test_chrono::test_chrono_system_clock_roundtrip(), test_chrono::test_chrono_system_clock_roundtrip_date(), test_chrono::test_chrono_system_clock_roundtrip_time(), test_numpy_dtypes::test_cls_and_dtype_conversion(), test_const_name::test_const_name(), test_exceptions::test_custom(), test_chrono::test_floating_point_duration(), test_pytypes::test_from_iterable(), test_pytypes::test_frozenset(), test_builtin_casters::test_int_long(), test_sequences_and_iterators::test_iterator_rvp(), test_exceptions::test_local_translator(), test_pytypes::test_memoryview(), test_pytypes::test_memoryview_from_buffer_empty_shape(), test_pytypes::test_memoryview_from_memory(), test_methods_and_attributes::test_metaclass_override(), test_class::test_override_static(), test_pytypes::test_populate_obj_str_attrs(), test_stl::test_return_vector_bool_raw_ptr(), test_pickling::test_roundtrip_simple_cpp_derived(), test_smart_ptr::test_smart_ptr(), and test_stl::test_variant_monostate().

◆ isinstance() [2/2]

bool isinstance ( handle  obj,
handle  type 
)
inline

Return true if obj is an instance of the type.

Definition at line 507 of file pytypes.h.

References handle::ptr().

◆ iter()

iterator iter ( handle  obj)
inline

◆ len()

size_t len ( handle  h)
inline

Get the length of a Python object.

Definition at line 2002 of file pytypes.h.

References handle::ptr().

Referenced by setup::build_expected_version_hex(), test_files::normalize_line_endings(), codespell_ignore_lines_from_errors::run(), dtype::strip_padding(), test_gil_scoped::test_all_basic_tests_completeness(), test_pytypes::test_bytearray(), test_callbacks::test_callback_num_times(), test_iostream::test_captured_large_string(), test_iostream::test_captured_utf8_2byte_offset0(), test_iostream::test_captured_utf8_2byte_offset1(), test_iostream::test_captured_utf8_3byte_offset0(), test_iostream::test_captured_utf8_3byte_offset1(), test_iostream::test_captured_utf8_3byte_offset2(), test_iostream::test_captured_utf8_4byte_offset0(), test_iostream::test_captured_utf8_4byte_offset1(), test_iostream::test_captured_utf8_4byte_offset2(), test_iostream::test_captured_utf8_4byte_offset3(), test_buffers::test_ctypes_array_1d(), test_buffers::test_ctypes_array_2d(), test_buffers::test_ctypes_from_buffer(), test_exceptions::test_flaky_exception_failure_point_str(), test_eigen_tensor::test_import_avoid_stl_array(), test_sequences_and_iterators::test_map_iterator(), test_stl_binders::test_map_string_double(), test_gil_scoped::test_multi_acquire_release_cross_module(), test_pytypes::test_populate_obj_str_attrs(), test_stl::test_return_vector_bool_raw_ptr(), test_sequences_and_iterators::test_sequence(), test_setuphelper::test_simple_setup_py(), test_stl::test_stl_ownership(), test_pytypes::test_surrogate_pairs_unicode_error(), test_stl::test_variant_monostate(), test_stl_binders::test_vector_buffer_numpy(), test_stl_binders::test_vector_int(), and test_files::tests_build_global_wheel().

◆ len_hint()

size_t len_hint ( handle  h)
inline

Get the length hint of a Python object.

Returns 0 when this cannot be determined.

Definition at line 2012 of file pytypes.h.

References handle::ptr().

Referenced by vector_modifiers().

◆ repr()

str repr ( handle  h)
inline

◆ setattr() [1/2]

void setattr ( handle  obj,
const char *  name,
handle  value 
)
inline

Definition at line 575 of file pytypes.h.

References handle::ptr().

◆ setattr() [2/2]

void setattr ( handle  obj,
handle  name,
handle  value 
)
inline