FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Improve performance by using Python C API to enter/exit context by tarasko · Pull Request #627 · MagicStack/uvloop · GitHub

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .pyx  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
22 changes: 9 additions & 13 deletions uvloop/loop.pyx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -92,31 +92,27 @@ cdef inline socket_dec_io_ref(sock):


cdef inline run_in_context(context, method):
# This method is internally used to workaround a reference issue that in
# certain circumstances, inlined context.run() will not hold a reference to
# the given method instance, which - if deallocated - will cause segfault.
# See also: edgedb/edgedb#2222
Py_INCREF(method)
Context_Enter(context)
try:
return context.run(method)
return method()
finally:
Py_DECREF(method)
Context_Exit(context)


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


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


# Used for deprecation and removal of `loop.create_datagram_endpoint()`'s
Expand Down

Back | FazBrowse Home | New Git URL