Library of Assembled Shared Sources
pyobject_special_methods.h
Go to the documentation of this file.
1/** @file
2 * @author Bram de Greve (bram@cocamware.com)
3 * @author Tom De Muer (tom@cocamware.com)
4 *
5 * *** BEGIN LICENSE INFORMATION ***
6 *
7 * The contents of this file are subject to the Common Public Attribution License
8 * Version 1.0 (the "License"); you may not use this file except in compliance with
9 * the License. You may obtain a copy of the License at
10 * http://lass.sourceforge.net/cpal-license. The License is based on the
11 * Mozilla Public License Version 1.1 but Sections 14 and 15 have been added to cover
12 * use of software over a computer network and provide for limited attribution for
13 * the Original Developer. In addition, Exhibit A has been modified to be consistent
14 * with Exhibit B.
15 *
16 * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
17 * WARRANTY OF ANY KIND, either express or implied. See the License for the specific
18 * language governing rights and limitations under the License.
19 *
20 * The Original Code is LASS - Library of Assembled Shared Sources.
21 *
22 * The Initial Developer of the Original Code is Bram de Greve and Tom De Muer.
23 * The Original Developer is the Initial Developer.
24 *
25 * All portions of the code written by the Initial Developer are:
26 * Copyright (C) 2004-2025 the Initial Developer.
27 * All Rights Reserved.
28 *
29 * Contributor(s):
30 *
31 * Alternatively, the contents of this file may be used under the terms of the
32 * GNU General Public License Version 2 or later (the GPL), in which case the
33 * provisions of GPL are applicable instead of those above. If you wish to allow use
34 * of your version of this file only under the terms of the GPL and not to allow
35 * others to use your version of this file under the CPAL, indicate your decision by
36 * deleting the provisions above and replace them with the notice and other
37 * provisions required by the GPL License. If you do not delete the provisions above,
38 * a recipient may use your version of this file under either the CPAL or the GPL.
39 *
40 * *** END LICENSE INFORMATION ***
41 */
42
43#ifndef LASS_GUARDIAN_OF_INCLUSION_UTIL_PYOBJECT_SPECIAL_METHODS_H
44#define LASS_GUARDIAN_OF_INCLUSION_UTIL_PYOBJECT_SPECIAL_METHODS_H
45
46#include "python_common.h"
47
48namespace lass
49{
50namespace python
51{
52
53namespace impl
54{
55 struct SpecialSlot
56 {
57 SpecialSlot( const char* name, int slot ) : name(name), slot(slot) {}
58 const char* name;
59 int slot;
60 };
61
62 struct UnarySlot : public SpecialSlot { UnarySlot( const char* name, int slot ) : SpecialSlot(name, slot) {} };
63 struct BinarySlot : public SpecialSlot { BinarySlot( const char* name, int slot ) : SpecialSlot(name, slot) {} };
64 struct TernarySlot : public SpecialSlot { TernarySlot( const char* name, int slot ) : SpecialSlot(name, slot) {} };
65 struct LenSlot : public SpecialSlot { LenSlot( const char* name, int slot ) : SpecialSlot(name, slot) {} };
66 struct ComparatorSlot : public SpecialSlot { ComparatorSlot( const char* name, int slot ) : SpecialSlot(name, slot) {} };
67 struct SsizeArgSlot : public SpecialSlot { SsizeArgSlot( const char* name, int slot ) : SpecialSlot(name, slot) {} };
68 struct SsizeSsizeArgSlot : public SpecialSlot { SsizeSsizeArgSlot( const char* name, int slot ) : SpecialSlot(name, slot) {} };
69 struct SsizeObjArgSlot : public SpecialSlot { SsizeObjArgSlot( const char* name, int slot ) : SpecialSlot(name, slot) {} };
70 struct SsizeSsizeObjArgSlot : public SpecialSlot { SsizeSsizeObjArgSlot( const char* name, int slot ) : SpecialSlot(name, slot) {} };
71 struct ObjObjSlot : public SpecialSlot { ObjObjSlot( const char* name, int slot ) : SpecialSlot(name, slot) {} };
72 struct ObjObjArgSlot : public SpecialSlot { ObjObjArgSlot( const char* name, int slot ) : SpecialSlot(name, slot) {} };
73 struct IterSlot : public SpecialSlot { IterSlot( const char* name, int slot ) : SpecialSlot(name, slot) {} };
74 struct IterNextSlot : public SpecialSlot { IterNextSlot( const char* name, int slot ) : SpecialSlot(name, slot) {} };
75 struct ArgKwSlot : public SpecialSlot { ArgKwSlot( const char* name, int slot ) : SpecialSlot(name, slot) {} };
76 struct InquirySlot: public SpecialSlot { InquirySlot( const char* name, int slot ) : SpecialSlot(name, slot) {} };
77
78 const int charPtrSlot = 1;
79 const int unarySlot = 2;
80 const int binarySlot = 3;
81 const int ternarySlot = 4;
82 const int lenSlot = 5;
83 const int comparatorSlot = 6;
84 const int ssizeArgSlot = 7;
85 const int ssizeSsizeArgSlot = 8;
86 const int ssizeObjArgSlot = 9;
87 const int ssizeSsizeObjArgSlot = 10;
88 const int objObjSlot = 11;
89 const int objObjArgSlot = 12;
90 const int iterSlot = 13;
91 const int iterNextSlot = 14;
92 const int argKwSlot = 15;
93 const int inquirySlot = 16;
94
95
96 template<int value> struct MetaInt { volatile const char dummy[value]; };
97
98 struct IsSpecialSlotTester
99 {
100 static MetaInt<charPtrSlot> test(char *);
101 static MetaInt<charPtrSlot> test(const char *);
102 static MetaInt<unarySlot> test(const UnarySlot&);
103 static MetaInt<binarySlot> test(const BinarySlot&);
104 static MetaInt<ternarySlot> test(const TernarySlot&);
105 static MetaInt<lenSlot> test(const LenSlot&);
106 static MetaInt<comparatorSlot> test(const ComparatorSlot&);
107 static MetaInt<ssizeArgSlot> test(const SsizeArgSlot&);
108 static MetaInt<ssizeSsizeArgSlot> test(const SsizeSsizeArgSlot&);
109 static MetaInt<ssizeObjArgSlot> test(const SsizeObjArgSlot&);
110 static MetaInt<ssizeSsizeObjArgSlot> test(const SsizeSsizeObjArgSlot&);
111 static MetaInt<objObjSlot> test(const ObjObjSlot&);
112 static MetaInt<objObjArgSlot> test(const ObjObjArgSlot&);
113 static MetaInt<iterSlot> test(const IterSlot&);
114 static MetaInt<iterNextSlot> test(const IterNextSlot&);
115 static MetaInt<argKwSlot> test(const ArgKwSlot&);
116 static MetaInt<inquirySlot> test(const InquirySlot&);
117 };
118
119 template<int value>
120 struct IsSpecialSlotTesterValue
121 {
122 };
123 template<> struct IsSpecialSlotTesterValue<sizeof(MetaInt<charPtrSlot>)> { typedef char* Type; };
124 template<> struct IsSpecialSlotTesterValue<sizeof(MetaInt<unarySlot>)> { typedef UnarySlot Type; };
125 template<> struct IsSpecialSlotTesterValue<sizeof(MetaInt<binarySlot>)> { typedef BinarySlot Type; };
126 template<> struct IsSpecialSlotTesterValue<sizeof(MetaInt<ternarySlot>)> { typedef TernarySlot Type; };
127 template<> struct IsSpecialSlotTesterValue<sizeof(MetaInt<lenSlot>)> { typedef LenSlot Type; };
128 template<> struct IsSpecialSlotTesterValue<sizeof(MetaInt<comparatorSlot>)> { typedef ComparatorSlot Type; };
129 template<> struct IsSpecialSlotTesterValue<sizeof(MetaInt<ssizeArgSlot>)> { typedef SsizeArgSlot Type; };
130 template<> struct IsSpecialSlotTesterValue<sizeof(MetaInt<ssizeSsizeArgSlot>)> { typedef SsizeSsizeArgSlot Type; };
131 template<> struct IsSpecialSlotTesterValue<sizeof(MetaInt<ssizeObjArgSlot>)> { typedef SsizeObjArgSlot Type; };
132 template<> struct IsSpecialSlotTesterValue<sizeof(MetaInt<ssizeSsizeObjArgSlot>)> { typedef SsizeSsizeObjArgSlot Type; };
133 template<> struct IsSpecialSlotTesterValue<sizeof(MetaInt<objObjSlot>)> { typedef ObjObjSlot Type; };
134 template<> struct IsSpecialSlotTesterValue<sizeof(MetaInt<objObjArgSlot>)> { typedef ObjObjArgSlot Type; };
135 template<> struct IsSpecialSlotTesterValue<sizeof(MetaInt<iterSlot>)> { typedef IterSlot Type; };
136 template<> struct IsSpecialSlotTesterValue<sizeof(MetaInt<iterNextSlot>)> { typedef IterNextSlot Type; };
137 template<> struct IsSpecialSlotTesterValue<sizeof(MetaInt<argKwSlot>)> { typedef ArgKwSlot Type; };
138 template<> struct IsSpecialSlotTesterValue<sizeof(MetaInt<inquirySlot>)> { typedef InquirySlot Type; };
139
140 #define SPECIAL_SLOT_TYPE( x ) lass::python::impl::IsSpecialSlotTesterValue<sizeof(lass::python::impl::IsSpecialSlotTester::test(x))>::Type
141
142}
143
144
145
146/** @namespace lass::python::methods
147 *
148 * Predefined constants for Python special methods (magic methods) that can be used as
149 * method names in class export macros.
150 *
151 * Available categories:
152 * - **Object Protocol**: `_call_`, `_repr_`, `_str_`
153 * - **Numeric Protocol**: `_add_`, `_sub_`, `_mul_`, `_neg_`, `_pos_`, etc.
154 * - **Comparison Protocol**: `_lt_`, `_le_`, `_eq_`, `_ne_`, `_gt_`, `_ge_`
155 * - **Sequence Protocol**: `_len_`, `_getitem_`, `_setitem_`, `_contains_`, etc.
156 * - **Mapping Protocol**: `map_len_`, `map_getitem_`, `map_setitem_`
157 * - **Iterator Protocol**: `_iter_`, `next`
158 *
159 * @note For these special methods to work correctly, you **must** use the constants defined
160 * in the `lass::python::methods` namespace. Using string literals like `"__add__"` will not
161 * work correctly.
162 * @ingroup SpecialMethods
163 */
164namespace methods
165{
166 /** @defgroup SpecialMethods Special Methods
167 * @copydoc lass::python::methods
168 * @ingroup Python
169 * @{
170 */
171
172 // special methods
173 const lass::python::impl::ArgKwSlot _call_("__call__", Py_tp_call); ///< `__call__` method (callable semantics)
174 const lass::python::impl::UnarySlot _repr_("__repr__", Py_tp_repr); ///< `__repr__` method (must always return a string)
175 const lass::python::impl::UnarySlot _str_("__str__", Py_tp_str); ///< `__str__` method (must always return a string)
176
177 // PyNumberMethods
178 // unary
179 const lass::python::impl::UnarySlot _neg_("__neg__", Py_nb_negative); ///< `__neg__` method (unary negation)
180 const lass::python::impl::UnarySlot _pos_("__pos__", Py_nb_positive); ///< `__pos__` method (unary positive)
181 const lass::python::impl::UnarySlot _abs_("__abs__", Py_nb_absolute); ///< `__abs__` method (absolute value)
182 const lass::python::impl::UnarySlot _invert_("__invert__", Py_nb_invert); ///< `__invert__` method (bitwise inversion)
183 const lass::python::impl::UnarySlot _int_("__int__", Py_nb_int); ///< `__int__` method (must return an integer)
184 const lass::python::impl::UnarySlot _long_("__long__", Py_nb_int); ///< alias for `__int__` method @deprecated
185 const lass::python::impl::UnarySlot _float_("__float__", Py_nb_float); ///< `__float__` method (must return a float)
186
187 // binary
188 const lass::python::impl::BinarySlot _add_("__add__", Py_nb_add); ///< `__add__` method (binary addition)
189 const lass::python::impl::BinarySlot _sub_("__sub__", Py_nb_subtract); ///< `__sub__` method (binary subtraction)
190 const lass::python::impl::BinarySlot _mul_("__mul__", Py_nb_multiply); ///< `__mul__` method (binary multiplication)
191 const lass::python::impl::BinarySlot _mod_("__mod__", Py_nb_remainder); ///< `__mod__` method (modulus)
192 const lass::python::impl::BinarySlot _lshift_("__lshift__", Py_nb_lshift); ///< `__lshift__` method (left shift)
193 const lass::python::impl::BinarySlot _rshift_("__rshift__", Py_nb_rshift); ///< `__rshift__` method (right shift)
194 const lass::python::impl::BinarySlot _and_("__and__", Py_nb_and); ///< `__and__` method (bitwise and)
195 const lass::python::impl::BinarySlot _xor_("__xor__", Py_nb_xor); ///< `__xor__` method (bitwise xor)
196 const lass::python::impl::BinarySlot _or_("__or__", Py_nb_or); ///< `__or__` method (bitwise or)
197 const lass::python::impl::BinarySlot _iadd_("__iadd__", Py_nb_inplace_add); ///< `__iadd__` method (in-place addition)
198 const lass::python::impl::BinarySlot _isub_("__isub__", Py_nb_inplace_subtract); ///< `__isub__` method (in-place subtraction)
199 const lass::python::impl::BinarySlot _imul_("__imul__", Py_nb_inplace_multiply); ///< `__imul__` method (in-place multiplication)
200 const lass::python::impl::BinarySlot _imod_("__imod__", Py_nb_inplace_remainder); ///< `__imod__` method (in-place modulus)
201 const lass::python::impl::BinarySlot _ilshift_("__ilshift__", Py_nb_inplace_lshift); ///< `__ilshift__` method (in-place left shift)
202 const lass::python::impl::BinarySlot _irshift_("__irshift__", Py_nb_inplace_rshift); ///< `__irshift__` method (in-place right shift)
203 const lass::python::impl::BinarySlot _iand_("__iand__", Py_nb_inplace_and); ///< `__iand__` method (in-place bitwise and)
204 const lass::python::impl::BinarySlot _ixor_("__ixor__", Py_nb_inplace_xor); ///< `__ixor__` method (in-place bitwise xor)
205 const lass::python::impl::BinarySlot _ior_("__ior__", Py_nb_inplace_or); ///< `__ior__` method (in-place bitwise or)
206 const lass::python::impl::BinarySlot _truediv_("__truediv__", Py_nb_true_divide); ///< `__truediv__` method (true division)
207 const lass::python::impl::BinarySlot _itruediv_("__itruediv__", Py_nb_inplace_true_divide); ///< `__itruediv__` method (in-place true division)
208 const lass::python::impl::BinarySlot _floordiv_("__floordiv__", Py_nb_floor_divide); ///< `__floordiv__` method (floor division)
209 const lass::python::impl::BinarySlot _ifloordiv_("__ifloordiv__", Py_nb_inplace_floor_divide); ///< `__ifloordiv__` method (in-place floor division)
210 const lass::python::impl::BinarySlot _matmul_("__matmul__", Py_nb_matrix_multiply); ///< `__matmul__` method (matrix multiplication)
211 const lass::python::impl::BinarySlot _imatmul_("__imatmul__", Py_nb_inplace_matrix_multiply); ///< `__imatmul__` method (in-place matrix multiplication)
212 const lass::python::impl::InquirySlot _bool_("__bool__", Py_nb_bool); ///< `__bool__` method (boolean conversion)
213 const lass::python::impl::InquirySlot _nonzero_ = _bool_; ///< alias for `__bool__` method @deprecated
214
215 const lass::python::impl::TernarySlot _pow_("__pow__", Py_nb_power); ///< `__pow__` method (exponentiation)
216 const lass::python::impl::TernarySlot _ipow_("__ipow__", Py_nb_inplace_power); ///< `__ipow__` method (in-place exponentiation)
217
218 // Comparators
219 const lass::python::impl::ComparatorSlot _lt_("__lt__", Py_LT); ///< `__lt__` method (less than)
220 const lass::python::impl::ComparatorSlot _le_("__le__", Py_LE); ///< `__le__` method (less than or equal)
221 const lass::python::impl::ComparatorSlot _eq_("__eq__", Py_EQ); ///< `__eq__` method (equal)
222 const lass::python::impl::ComparatorSlot _ne_("__ne__", Py_NE); ///< `__ne__` method (not equal)
223 const lass::python::impl::ComparatorSlot _gt_("__gt__", Py_GT); ///< `__gt__` method (greater than)
224 const lass::python::impl::ComparatorSlot _ge_("__ge__", Py_GE); ///< `__ge__` method (greater than or equal)
225
226
227 // shared between PySequenceMethods and PyMappingMethods
228 // the PySequenceMethods gets priority in this case
229 const lass::python::impl::LenSlot _len_("__seq_len__", Py_sq_length); ///< `__len__` method (length of the sequence)
230 const lass::python::impl::SsizeArgSlot _getitem_("__seq_getitem__", Py_sq_item); ///< `__getitem__` method (get item by index)
231 const lass::python::impl::SsizeObjArgSlot _setitem_("__seq_setitem__", Py_sq_ass_item); ///< `__setitem__` method (set item by index)
232
233
234 // PySequenceMethods
235 const lass::python::impl::LenSlot seq_len_("__seq_len__", Py_sq_length); ///< `__len__` method (length of the sequence)
236 const lass::python::impl::BinarySlot _concat_("__concat__", Py_sq_concat); ///< `__concat__` method (concatenation)
237 const lass::python::impl::SsizeArgSlot _repeat_("__repeat__", Py_sq_repeat); ///< `__repeat__` method (repetition)
238 const lass::python::impl::SsizeArgSlot seq_getitem_("__seq_getitem__", Py_sq_item); ///< `__getitem__` method (get item by index)
239 const lass::python::impl::SsizeObjArgSlot seq_setitem_("__seq_setitem__", Py_sq_ass_item); ///< `__setitem__` method (set item by index)
240 const lass::python::impl::ObjObjSlot _contains_("__contains__", Py_sq_contains); ///< `__contains__` method (membership test)
241 const lass::python::impl::BinarySlot _iconcat_("__iconcat__", Py_sq_inplace_concat); ///< `__iconcat__` method (in-place concatenation)
242 const lass::python::impl::SsizeArgSlot _irepeat_("__irepeat__", Py_sq_inplace_repeat); ///< `__irepeat__` method (in-place repetition)
243
244 // PyMappingMethods
245 const lass::python::impl::LenSlot map_len_("__map_len__", Py_mp_length); ///< `__len__` method (length of the mapping)
246 const lass::python::impl::BinarySlot map_getitem_("__map_getitem__", Py_mp_subscript); ///< `__getitem__` method (get item by key)
247 const lass::python::impl::ObjObjArgSlot map_setitem_("__map_setitem__", Py_mp_ass_subscript); ///< `__setitem__` method (set item by key)
248 const lass::python::impl::ObjObjArgSlot map_delitem_ = map_setitem_; ///< `__delitem__` method (delete item by key, shares same slot as `__setitem__`)
249
250 // Iterator Protocol
251 const lass::python::impl::IterSlot _iter_("__iter__", Py_tp_iter); ///< `__iter__` method (iterator)
252 const lass::python::impl::IterNextSlot next("__next__", Py_tp_iternext); ///< `__next__` method (iterator next)
253
254 /** @} */
255}
256
257}
258}
259
260#endif
const lass::python::impl::BinarySlot _matmul_("__matmul__", Py_nb_matrix_multiply)
__matmul__ method (matrix multiplication)
const lass::python::impl::SsizeArgSlot _irepeat_("__irepeat__", Py_sq_inplace_repeat)
__irepeat__ method (in-place repetition)
const lass::python::impl::BinarySlot _iand_("__iand__", Py_nb_inplace_and)
__iand__ method (in-place bitwise and)
const lass::python::impl::BinarySlot _imul_("__imul__", Py_nb_inplace_multiply)
__imul__ method (in-place multiplication)
const lass::python::impl::SsizeObjArgSlot seq_setitem_("__seq_setitem__", Py_sq_ass_item)
__setitem__ method (set item by index)
const lass::python::impl::BinarySlot _lshift_("__lshift__", Py_nb_lshift)
__lshift__ method (left shift)
const lass::python::impl::UnarySlot _float_("__float__", Py_nb_float)
__float__ method (must return a float)
const lass::python::impl::IterSlot _iter_("__iter__", Py_tp_iter)
__iter__ method (iterator)
const lass::python::impl::ObjObjArgSlot map_delitem_
__delitem__ method (delete item by key, shares same slot as __setitem__)
const lass::python::impl::ComparatorSlot _lt_("__lt__", Py_LT)
__lt__ method (less than)
const lass::python::impl::BinarySlot _imod_("__imod__", Py_nb_inplace_remainder)
__imod__ method (in-place modulus)
const lass::python::impl::BinarySlot _iadd_("__iadd__", Py_nb_inplace_add)
__iadd__ method (in-place addition)
const lass::python::impl::UnarySlot _pos_("__pos__", Py_nb_positive)
__pos__ method (unary positive)
const lass::python::impl::BinarySlot _ixor_("__ixor__", Py_nb_inplace_xor)
__ixor__ method (in-place bitwise xor)
const lass::python::impl::ComparatorSlot _ne_("__ne__", Py_NE)
__ne__ method (not equal)
const lass::python::impl::ComparatorSlot _gt_("__gt__", Py_GT)
__gt__ method (greater than)
const lass::python::impl::SsizeObjArgSlot _setitem_("__seq_setitem__", Py_sq_ass_item)
__setitem__ method (set item by index)
const lass::python::impl::SsizeArgSlot _getitem_("__seq_getitem__", Py_sq_item)
__getitem__ method (get item by index)
const lass::python::impl::UnarySlot _repr_("__repr__", Py_tp_repr)
__repr__ method (must always return a string)
const lass::python::impl::BinarySlot _add_("__add__", Py_nb_add)
__add__ method (binary addition)
const lass::python::impl::BinarySlot _and_("__and__", Py_nb_and)
__and__ method (bitwise and)
const lass::python::impl::BinarySlot _ilshift_("__ilshift__", Py_nb_inplace_lshift)
__ilshift__ method (in-place left shift)
const lass::python::impl::IterNextSlot next("__next__", Py_tp_iternext)
__next__ method (iterator next)
const lass::python::impl::BinarySlot _iconcat_("__iconcat__", Py_sq_inplace_concat)
__iconcat__ method (in-place concatenation)
const lass::python::impl::InquirySlot _bool_("__bool__", Py_nb_bool)
__bool__ method (boolean conversion)
const lass::python::impl::TernarySlot _pow_("__pow__", Py_nb_power)
__pow__ method (exponentiation)
const lass::python::impl::BinarySlot _mul_("__mul__", Py_nb_multiply)
__mul__ method (binary multiplication)
const lass::python::impl::ArgKwSlot _call_("__call__", Py_tp_call)
__call__ method (callable semantics)
const lass::python::impl::BinarySlot _xor_("__xor__", Py_nb_xor)
__xor__ method (bitwise xor)
const lass::python::impl::ObjObjSlot _contains_("__contains__", Py_sq_contains)
__contains__ method (membership test)
const lass::python::impl::BinarySlot _truediv_("__truediv__", Py_nb_true_divide)
__truediv__ method (true division)
const lass::python::impl::ComparatorSlot _eq_("__eq__", Py_EQ)
__eq__ method (equal)
const lass::python::impl::BinarySlot _ior_("__ior__", Py_nb_inplace_or)
__ior__ method (in-place bitwise or)
const lass::python::impl::SsizeArgSlot seq_getitem_("__seq_getitem__", Py_sq_item)
__getitem__ method (get item by index)
const lass::python::impl::BinarySlot _irshift_("__irshift__", Py_nb_inplace_rshift)
__irshift__ method (in-place right shift)
const lass::python::impl::BinarySlot _mod_("__mod__", Py_nb_remainder)
__mod__ method (modulus)
const lass::python::impl::ObjObjArgSlot map_setitem_("__map_setitem__", Py_mp_ass_subscript)
__setitem__ method (set item by key)
const lass::python::impl::UnarySlot _long_("__long__", Py_nb_int)
alias for __int__ method
const lass::python::impl::LenSlot map_len_("__map_len__", Py_mp_length)
__len__ method (length of the mapping)
const lass::python::impl::BinarySlot _imatmul_("__imatmul__", Py_nb_inplace_matrix_multiply)
__imatmul__ method (in-place matrix multiplication)
const lass::python::impl::ComparatorSlot _ge_("__ge__", Py_GE)
__ge__ method (greater than or equal)
const lass::python::impl::BinarySlot _itruediv_("__itruediv__", Py_nb_inplace_true_divide)
__itruediv__ method (in-place true division)
const lass::python::impl::BinarySlot map_getitem_("__map_getitem__", Py_mp_subscript)
__getitem__ method (get item by key)
const lass::python::impl::BinarySlot _or_("__or__", Py_nb_or)
__or__ method (bitwise or)
const lass::python::impl::UnarySlot _abs_("__abs__", Py_nb_absolute)
__abs__ method (absolute value)
const lass::python::impl::ComparatorSlot _le_("__le__", Py_LE)
__le__ method (less than or equal)
const lass::python::impl::LenSlot seq_len_("__seq_len__", Py_sq_length)
__len__ method (length of the sequence)
const lass::python::impl::InquirySlot _nonzero_
alias for __bool__ method
const lass::python::impl::UnarySlot _neg_("__neg__", Py_nb_negative)
__neg__ method (unary negation)
const lass::python::impl::UnarySlot _invert_("__invert__", Py_nb_invert)
__invert__ method (bitwise inversion)
const lass::python::impl::UnarySlot _int_("__int__", Py_nb_int)
__int__ method (must return an integer)
const lass::python::impl::BinarySlot _sub_("__sub__", Py_nb_subtract)
__sub__ method (binary subtraction)
const lass::python::impl::LenSlot _len_("__seq_len__", Py_sq_length)
__len__ method (length of the sequence)
const lass::python::impl::BinarySlot _ifloordiv_("__ifloordiv__", Py_nb_inplace_floor_divide)
__ifloordiv__ method (in-place floor division)
const lass::python::impl::BinarySlot _concat_("__concat__", Py_sq_concat)
__concat__ method (concatenation)
const lass::python::impl::BinarySlot _rshift_("__rshift__", Py_nb_rshift)
__rshift__ method (right shift)
const lass::python::impl::BinarySlot _floordiv_("__floordiv__", Py_nb_floor_divide)
__floordiv__ method (floor division)
const lass::python::impl::BinarySlot _isub_("__isub__", Py_nb_inplace_subtract)
__isub__ method (in-place subtraction)
const lass::python::impl::UnarySlot _str_("__str__", Py_tp_str)
__str__ method (must always return a string)
const lass::python::impl::SsizeArgSlot _repeat_("__repeat__", Py_sq_repeat)
__repeat__ method (repetition)
const lass::python::impl::TernarySlot _ipow_("__ipow__", Py_nb_inplace_power)
__ipow__ method (in-place exponentiation)
Predefined constants for Python special methods (magic methods) that can be used as method names in c...
Comprehensive C++ to Python binding library.
Library for Assembled Shared Sources.
Definition config.h:53