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) |
Unless stated otherwise, the following C++ functions behave the same as their Python counterparts.
|
inline |
Definition at line 531 of file pytypes.h.
References handle::ptr().
Definition at line 525 of file pytypes.h.
References handle::ptr().
Definition at line 545 of file pytypes.h.
References handle::ptr().
Definition at line 561 of file pytypes.h.
References handle::ptr().
Definition at line 537 of file pytypes.h.
References handle::ptr().
Referenced by uhal::_add_int_method_to_ValWord(), module_::def(), class_< type_, options >::def(), class_< type_, options >::def_static(), str_attr::get(), obj_attr::get(), get_type_override(), test_numpy_array::test_argument_conversions(), test_eigen_tensor::test_convert_tensor_to_py(), test_builtin_casters::test_int_long(), test_multiple_inheritance::test_multiple_inheritance_python_many_bases(), test_pickling::test_pickle_simple_callable(), test_methods_and_attributes::test_property_return_value_policies(), test_eigen_tensor::test_reference_internal(), test_pickling::test_roundtrip(), test_pickling::test_roundtrip_with_dict(), and type_caster_generic::try_load_foreign_module_local().
Definition at line 553 of file pytypes.h.
References handle::ptr().
|
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().
|
inline |
Definition at line 521 of file pytypes.h.
References handle::ptr().
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().
Definition at line 581 of file pytypes.h.
References hash(), and handle::ptr().
Referenced by pugi::xml_document::_create(), pugi::xml_document::_destroy(), pugi::xpath_variable_set::_find(), pugi::xpath_variable_set::add(), hash(), type_hash::operator()(), and TEST_SUBMODULE().
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().
Return true if obj
is an instance of the type
.
Definition at line 507 of file pytypes.h.
References handle::ptr().
Definition at line 2042 of file pytypes.h.
References handle::ptr().
Referenced by object_api< Derived >::begin(), multi_array_iterator< N >::increment_common_iterator(), uhal::tests::job_multiple(), PyIterable_Check(), TEST_CASE(), test_pytypes::test_cpp_iterators(), test_pytypes::test_from_iterable(), test_sequences_and_iterators::test_iterator_passthrough(), test_sequences_and_iterators::test_map_iterator(), test_sequences_and_iterators::test_python_iterator_in_cpp(), test_sequences_and_iterators::test_sequence(), TEST_SUBMODULE(), and uhal::tests::UHAL_TESTS_DEFINE_CLIENT_TEST_CASES().
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().
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().
Definition at line 2027 of file pytypes.h.
References handle::ptr().
Referenced by cpp_function::initialize_generic(), test_enum::test_implicit_conversion(), test_eigen::test_negative_stride_from_python(), test_eigen_matrix::test_negative_stride_from_python(), test_class::test_obj_class_name(), test_numpy_array::test_overload_resolution(), test_opaque_types::test_pointers(), test_class::test_repr(), test_sequences_and_iterators::test_sequence(), and test_enum::test_unscoped_enum().
Definition at line 575 of file pytypes.h.
References handle::ptr().
Definition at line 569 of file pytypes.h.
References handle::ptr().
Referenced by uhal::_add_int_method_to_ValWord(), generic_type::initialize(), make_default_metaclass(), make_new_python_type(), make_object_base_type(), make_static_property_type(), str_attr::set(), obj_attr::set(), setstate(), and test_pickling::test_roundtrip_simple_cpp_derived().