Library of Assembled Shared Sources
 
Loading...
Searching...
No Matches
Special Methods

Detailed Description

Predefined constants for Python special methods (magic methods) that can be used as method names in class export macros.

Available categories:

Note
For these special methods to work correctly, you must use the constants defined in the lass::python::methods namespace. Using string literals like "__add__" will not work correctly.

Namespaces

namespace  lass::python::methods
 Predefined constants for Python special methods (magic methods) that can be used as method names in class export macros.
 

Functions

const lass::python::impl::ArgKwSlot lass::python::methods::_call_ ("__call__", Py_tp_call)
 __call__ method (callable semantics)
 
const lass::python::impl::UnarySlot lass::python::methods::_repr_ ("__repr__", Py_tp_repr)
 __repr__ method (must always return a string)
 
const lass::python::impl::UnarySlot lass::python::methods::_str_ ("__str__", Py_tp_str)
 __str__ method (must always return a string)
 
const lass::python::impl::UnarySlot lass::python::methods::_neg_ ("__neg__", Py_nb_negative)
 __neg__ method (unary negation)
 
const lass::python::impl::UnarySlot lass::python::methods::_pos_ ("__pos__", Py_nb_positive)
 __pos__ method (unary positive)
 
const lass::python::impl::UnarySlot lass::python::methods::_abs_ ("__abs__", Py_nb_absolute)
 __abs__ method (absolute value)
 
const lass::python::impl::UnarySlot lass::python::methods::_invert_ ("__invert__", Py_nb_invert)
 __invert__ method (bitwise inversion)
 
const lass::python::impl::UnarySlot lass::python::methods::_int_ ("__int__", Py_nb_int)
 __int__ method (must return an integer)
 
const lass::python::impl::UnarySlot lass::python::methods::_long_ ("__long__", Py_nb_int)
 alias for __int__ method
 
const lass::python::impl::UnarySlot lass::python::methods::_float_ ("__float__", Py_nb_float)
 __float__ method (must return a float)
 
const lass::python::impl::BinarySlot lass::python::methods::_add_ ("__add__", Py_nb_add)
 __add__ method (binary addition)
 
const lass::python::impl::BinarySlot lass::python::methods::_sub_ ("__sub__", Py_nb_subtract)
 __sub__ method (binary subtraction)
 
const lass::python::impl::BinarySlot lass::python::methods::_mul_ ("__mul__", Py_nb_multiply)
 __mul__ method (binary multiplication)
 
const lass::python::impl::BinarySlot lass::python::methods::_mod_ ("__mod__", Py_nb_remainder)
 __mod__ method (modulus)
 
const lass::python::impl::BinarySlot lass::python::methods::_lshift_ ("__lshift__", Py_nb_lshift)
 __lshift__ method (left shift)
 
const lass::python::impl::BinarySlot lass::python::methods::_rshift_ ("__rshift__", Py_nb_rshift)
 __rshift__ method (right shift)
 
const lass::python::impl::BinarySlot lass::python::methods::_and_ ("__and__", Py_nb_and)
 __and__ method (bitwise and)
 
const lass::python::impl::BinarySlot lass::python::methods::_xor_ ("__xor__", Py_nb_xor)
 __xor__ method (bitwise xor)
 
const lass::python::impl::BinarySlot lass::python::methods::_or_ ("__or__", Py_nb_or)
 __or__ method (bitwise or)
 
const lass::python::impl::BinarySlot lass::python::methods::_iadd_ ("__iadd__", Py_nb_inplace_add)
 __iadd__ method (in-place addition)
 
const lass::python::impl::BinarySlot lass::python::methods::_isub_ ("__isub__", Py_nb_inplace_subtract)
 __isub__ method (in-place subtraction)
 
const lass::python::impl::BinarySlot lass::python::methods::_imul_ ("__imul__", Py_nb_inplace_multiply)
 __imul__ method (in-place multiplication)
 
const lass::python::impl::BinarySlot lass::python::methods::_imod_ ("__imod__", Py_nb_inplace_remainder)
 __imod__ method (in-place modulus)
 
const lass::python::impl::BinarySlot lass::python::methods::_ilshift_ ("__ilshift__", Py_nb_inplace_lshift)
 __ilshift__ method (in-place left shift)
 
const lass::python::impl::BinarySlot lass::python::methods::_irshift_ ("__irshift__", Py_nb_inplace_rshift)
 __irshift__ method (in-place right shift)
 
const lass::python::impl::BinarySlot lass::python::methods::_iand_ ("__iand__", Py_nb_inplace_and)
 __iand__ method (in-place bitwise and)
 
const lass::python::impl::BinarySlot lass::python::methods::_ixor_ ("__ixor__", Py_nb_inplace_xor)
 __ixor__ method (in-place bitwise xor)
 
const lass::python::impl::BinarySlot lass::python::methods::_ior_ ("__ior__", Py_nb_inplace_or)
 __ior__ method (in-place bitwise or)
 
const lass::python::impl::BinarySlot lass::python::methods::_truediv_ ("__truediv__", Py_nb_true_divide)
 __truediv__ method (true division)
 
const lass::python::impl::BinarySlot lass::python::methods::_itruediv_ ("__itruediv__", Py_nb_inplace_true_divide)
 __itruediv__ method (in-place true division)
 
const lass::python::impl::BinarySlot lass::python::methods::_floordiv_ ("__floordiv__", Py_nb_floor_divide)
 __floordiv__ method (floor division)
 
const lass::python::impl::BinarySlot lass::python::methods::_ifloordiv_ ("__ifloordiv__", Py_nb_inplace_floor_divide)
 __ifloordiv__ method (in-place floor division)
 
const lass::python::impl::BinarySlot lass::python::methods::_matmul_ ("__matmul__", Py_nb_matrix_multiply)
 __matmul__ method (matrix multiplication)
 
const lass::python::impl::BinarySlot lass::python::methods::_imatmul_ ("__imatmul__", Py_nb_inplace_matrix_multiply)
 __imatmul__ method (in-place matrix multiplication)
 
const lass::python::impl::InquirySlot lass::python::methods::_bool_ ("__bool__", Py_nb_bool)
 __bool__ method (boolean conversion)
 
const lass::python::impl::TernarySlot lass::python::methods::_pow_ ("__pow__", Py_nb_power)
 __pow__ method (exponentiation)
 
const lass::python::impl::TernarySlot lass::python::methods::_ipow_ ("__ipow__", Py_nb_inplace_power)
 __ipow__ method (in-place exponentiation)
 
const lass::python::impl::ComparatorSlot lass::python::methods::_lt_ ("__lt__", Py_LT)
 __lt__ method (less than)
 
const lass::python::impl::ComparatorSlot lass::python::methods::_le_ ("__le__", Py_LE)
 __le__ method (less than or equal)
 
const lass::python::impl::ComparatorSlot lass::python::methods::_eq_ ("__eq__", Py_EQ)
 __eq__ method (equal)
 
const lass::python::impl::ComparatorSlot lass::python::methods::_ne_ ("__ne__", Py_NE)
 __ne__ method (not equal)
 
const lass::python::impl::ComparatorSlot lass::python::methods::_gt_ ("__gt__", Py_GT)
 __gt__ method (greater than)
 
const lass::python::impl::ComparatorSlot lass::python::methods::_ge_ ("__ge__", Py_GE)
 __ge__ method (greater than or equal)
 
const lass::python::impl::LenSlot lass::python::methods::_len_ ("__seq_len__", Py_sq_length)
 __len__ method (length of the sequence)
 
const lass::python::impl::SsizeArgSlot lass::python::methods::_getitem_ ("__seq_getitem__", Py_sq_item)
 __getitem__ method (get item by index)
 
const lass::python::impl::SsizeObjArgSlot lass::python::methods::_setitem_ ("__seq_setitem__", Py_sq_ass_item)
 __setitem__ method (set item by index)
 
const lass::python::impl::LenSlot lass::python::methods::seq_len_ ("__seq_len__", Py_sq_length)
 __len__ method (length of the sequence)
 
const lass::python::impl::BinarySlot lass::python::methods::_concat_ ("__concat__", Py_sq_concat)
 __concat__ method (concatenation)
 
const lass::python::impl::SsizeArgSlot lass::python::methods::_repeat_ ("__repeat__", Py_sq_repeat)
 __repeat__ method (repetition)
 
const lass::python::impl::SsizeArgSlot lass::python::methods::seq_getitem_ ("__seq_getitem__", Py_sq_item)
 __getitem__ method (get item by index)
 
const lass::python::impl::SsizeObjArgSlot lass::python::methods::seq_setitem_ ("__seq_setitem__", Py_sq_ass_item)
 __setitem__ method (set item by index)
 
const lass::python::impl::ObjObjSlot lass::python::methods::_contains_ ("__contains__", Py_sq_contains)
 __contains__ method (membership test)
 
const lass::python::impl::BinarySlot lass::python::methods::_iconcat_ ("__iconcat__", Py_sq_inplace_concat)
 __iconcat__ method (in-place concatenation)
 
const lass::python::impl::SsizeArgSlot lass::python::methods::_irepeat_ ("__irepeat__", Py_sq_inplace_repeat)
 __irepeat__ method (in-place repetition)
 
const lass::python::impl::LenSlot lass::python::methods::map_len_ ("__map_len__", Py_mp_length)
 __len__ method (length of the mapping)
 
const lass::python::impl::BinarySlot lass::python::methods::map_getitem_ ("__map_getitem__", Py_mp_subscript)
 __getitem__ method (get item by key)
 
const lass::python::impl::ObjObjArgSlot lass::python::methods::map_setitem_ ("__map_setitem__", Py_mp_ass_subscript)
 __setitem__ method (set item by key)
 
const lass::python::impl::IterSlot lass::python::methods::_iter_ ("__iter__", Py_tp_iter)
 __iter__ method (iterator)
 
const lass::python::impl::IterNextSlot lass::python::methods::next ("__next__", Py_tp_iternext)
 __next__ method (iterator next)
 

Variables

const lass::python::impl::InquirySlot lass::python::methods::_nonzero_ = _bool_
 alias for __bool__ method
 
const lass::python::impl::ObjObjArgSlot lass::python::methods::map_delitem_ = map_setitem_
 __delitem__ method (delete item by key, shares same slot as __setitem__)
 

Function Documentation

◆ _long_()

const lass::python::impl::UnarySlot lass::python::methods::_long_ ( "__long__" ,
Py_nb_int  )

alias for __int__ method

Deprecated

Variable Documentation

◆ _nonzero_

const lass::python::impl::InquirySlot lass::python::methods::_nonzero_ = _bool_

alias for __bool__ method

Deprecated

Definition at line 213 of file pyobject_special_methods.h.