MCPcopy Index your code
hub / github.com/dgrunwald/rust-cpython / numeric_operator

Function numeric_operator

src/py_class/py_class_impl.py:746–762  ·  view source on GitHub ↗
(special_name, arity, slot)

Source from the content-addressed store, hash-verified

744
745@special_method
746def numeric_operator(special_name, arity, slot):
747 if arity == 'binary':
748 argnames = ['left', 'right']
749 elif arity == 'ternary':
750 argnames = ['left', 'right', 'ex']
751 else:
752 error("Invalid arity %s" % arity)
753 def_args_str = ', '.join("$%s:ident" % name for name in argnames)
754 impl_args_str = ' '.join("{ $%s : &$crate::PyObject = {} }" % name for name in argnames)
755 generate_case(
756 pattern='def %s(%s) -> $res_type:ty { $($body:tt)* }'
757 % (special_name, def_args_str),
758 new_impl='$crate::py_class_impl_item! { $class, $py, pub, %s() $res_type; { $($body)* } [ %s ] }'
759 % (special_name, impl_args_str),
760 new_slots=[(slot, '$crate::py_class_numeric_slot!(%s $class::%s)' % (arity, special_name))]
761 )
762 error('Invalid signature for %s numeric operator %s' % (arity, special_name))(special_name)
763
764@special_method
765def reflected_numeric_operator(special_name):

Callers 1

py_class_impl.pyFile · 0.85

Calls 2

errorFunction · 0.85
generate_caseFunction · 0.85

Tested by

no test coverage detected