Skip to content

Commit

Permalink
Optimize run_in_context calls
Browse files Browse the repository at this point in the history
  • Loading branch information
taras committed Sep 8, 2024
1 parent 79d5dcd commit 50497f9
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions uvloop/loop.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -98,23 +98,35 @@ cdef inline run_in_context(context, method):
# See also: edgedb/edgedb#2222
Py_INCREF(method)
try:
return context.run(method)
Context_Enter(context)
try:
return method()
finally:
Context_Exit(context)
finally:
Py_DECREF(method)


cdef inline run_in_context1(context, method, arg):
Py_INCREF(method)
try:
return context.run(method, arg)
Context_Enter(context)
try:
return method(arg)
finally:
Context_Exit(context)
finally:
Py_DECREF(method)


cdef inline run_in_context2(context, method, arg1, arg2):
Py_INCREF(method)
try:
return context.run(method, arg1, arg2)
Context_Enter(context)
try:
return method(arg1, arg2)
finally:
Context_Exit(context)
finally:
Py_DECREF(method)

Expand Down

0 comments on commit 50497f9

Please sign in to comment.