Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update sortedmapp to use meth_fastcall #233

Merged
merged 1 commit into from
Jan 20, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions atom/src/sortedmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,13 +401,12 @@ SortedMap_contains( SortedMap* self, PyObject* key )


PyObject*
SortedMap_get( SortedMap* self, PyObject* args )
SortedMap_get( SortedMap* self, PyObject*const *args, Py_ssize_t nargs )
{
Py_ssize_t nargs = PyTuple_GET_SIZE( args );
if( nargs == 1 )
return self->getitem( PyTuple_GET_ITEM( args, 0 ), Py_None );
return self->getitem( args[0], Py_None );
if( nargs == 2 )
return self->getitem( PyTuple_GET_ITEM( args, 0 ), PyTuple_GET_ITEM( args, 1 ) );
return self->getitem( args[0], args[1] );
std::ostringstream ostr;
if( nargs > 2 )
ostr << "get() expected at most 2 arguments, got " << nargs;
Expand All @@ -418,13 +417,12 @@ SortedMap_get( SortedMap* self, PyObject* args )


PyObject*
SortedMap_pop( SortedMap* self, PyObject* args )
SortedMap_pop( SortedMap* self, PyObject*const *args, Py_ssize_t nargs )
{
Py_ssize_t nargs = PyTuple_GET_SIZE( args );
if( nargs == 1 )
return self->pop( PyTuple_GET_ITEM( args, 0 ) );
return self->pop( args[0] );
if( nargs == 2 )
return self->getitem( PyTuple_GET_ITEM( args, 0 ), PyTuple_GET_ITEM( args, 1 ) );
return self->getitem( args[0], args[1] );
std::ostringstream ostr;
if( nargs > 2 )
ostr << "pop() expected at most 2 arguments, got " << nargs;
Expand Down Expand Up @@ -541,9 +539,9 @@ SortedMap_sizeof( SortedMap* self, PyObject* args )

static PyMethodDef
SortedMap_methods[] = {
{ "get", ( PyCFunction )SortedMap_get, METH_VARARGS,
{ "get", ( PyCFunction )SortedMap_get, METH_FASTCALL,
"" },
{ "pop", ( PyCFunction )SortedMap_pop, METH_VARARGS,
{ "pop", ( PyCFunction )SortedMap_pop, METH_FASTCALL,
"" },
{ "clear", ( PyCFunction)SortedMap_clearmethod, METH_NOARGS,
"" },
Expand Down
Loading