@@ -189,19 +189,18 @@ CAtom_get_member( PyObject* self, PyObject* name )
189189
190190
191191PyObject*
192- CAtom_observe ( CAtom* self, PyObject* args )
192+ CAtom_observe ( CAtom* self, PyObject*const * args, Py_ssize_t n )
193193{
194- const size_t n = PyTuple_GET_SIZE ( args );
195194 if ( n < 2 || n > 3 )
196195 return cppy::type_error ( " observe() takes exactly 2 or 3 arguments" );
197- PyObject* topic = PyTuple_GET_ITEM ( args, 0 ) ;
198- PyObject* callback = PyTuple_GET_ITEM ( args, 1 ) ;
196+ PyObject* topic = args[ 0 ] ;
197+ PyObject* callback = args[ 1 ] ;
199198 if ( !PyCallable_Check ( callback ) )
200199 return cppy::type_error ( callback, " callable" );
201200 uint8_t change_types = ChangeType::Any;
202201 if ( n == 3 )
203202 {
204- PyObject* types = PyTuple_GET_ITEM ( args, 2 ) ;
203+ PyObject* types = args[ 2 ] ;
205204 if ( !PyLong_Check ( types ) )
206205 return cppy::type_error ( types, " int" );
207206 change_types = PyLong_AsLong ( types ) & 0xFF ;
@@ -300,17 +299,15 @@ _CAtom_unobserve_2( CAtom* self, PyObject* topic, PyObject* callback )
300299
301300
302301PyObject*
303- CAtom_unobserve ( CAtom* self, PyObject* args )
302+ CAtom_unobserve ( CAtom* self, PyObject*const * args, Py_ssize_t n_args )
304303{
305- Py_ssize_t n_args = PyTuple_GET_SIZE ( args );
306- if ( n_args > 2 )
307- return cppy::type_error ( " unobserve() takes at most 2 arguments" );
308304 if ( n_args == 0 )
309305 return _CAtom_unobserve_0 ( self );
310306 if ( n_args == 1 )
311- return _CAtom_unobserve_1 ( self, PyTuple_GET_ITEM ( args, 0 ) );
312- return _CAtom_unobserve_2 ( self, PyTuple_GET_ITEM ( args, 0 ),
313- PyTuple_GET_ITEM ( args, 1 ) );
307+ return _CAtom_unobserve_1 ( self, args[0 ] );
308+ if ( n_args == 2 )
309+ return _CAtom_unobserve_2 ( self, args[0 ], args[1 ] );
310+ return cppy::type_error ( " unobserve() takes at most 2 arguments" );
314311}
315312
316313
@@ -322,12 +319,12 @@ CAtom_has_observers( CAtom* self, PyObject* topic )
322319
323320
324321PyObject*
325- CAtom_has_observer ( CAtom* self, PyObject* args )
322+ CAtom_has_observer ( CAtom* self, PyObject*const * args, Py_ssize_t n )
326323{
327- if ( PyTuple_GET_SIZE ( args ) != 2 )
324+ if ( n != 2 )
328325 return cppy::type_error ( " has_observer() takes exactly 2 arguments" );
329- PyObject* topic = PyTuple_GET_ITEM ( args, 0 ) ;
330- PyObject* callback = PyTuple_GET_ITEM ( args, 1 ) ;
326+ PyObject* topic = args[ 0 ] ;
327+ PyObject* callback = args[ 1 ] ;
331328 if ( !utils::str_check ( topic ) )
332329 return cppy::type_error ( topic, " str" );
333330 if ( !PyCallable_Check ( callback ) )
@@ -488,13 +485,13 @@ CAtom_methods[] = {
488485 " Enable or disable notifications for the atom." },
489486 { " get_member" , ( PyCFunction )CAtom_get_member, METH_O,
490487 " Get the named member for the atom." },
491- { " observe" , ( PyCFunction )CAtom_observe, METH_VARARGS ,
488+ { " observe" , ( PyCFunction )CAtom_observe, METH_FASTCALL ,
492489 " Register an observer callback to observe changes on the given topic(s)." },
493- { " unobserve" , ( PyCFunction )CAtom_unobserve, METH_VARARGS ,
490+ { " unobserve" , ( PyCFunction )CAtom_unobserve, METH_FASTCALL ,
494491 " Unregister an observer callback for the given topic(s)." },
495492 { " has_observers" , ( PyCFunction )CAtom_has_observers, METH_O,
496493 " Get whether the atom has observers for a given topic." },
497- { " has_observer" , ( PyCFunction )CAtom_has_observer, METH_VARARGS ,
494+ { " has_observer" , ( PyCFunction )CAtom_has_observer, METH_FASTCALL ,
498495 " Get whether the atom has the given observer for a given topic." },
499496 { " notify" , ( PyCFunction )CAtom_notify, METH_VARARGS | METH_KEYWORDS,
500497 " Call the registered observers for a given topic with positional and keyword arguments." },
0 commit comments