Skip to content

Commit

Permalink
Make a global out of sysconfig call
Browse files Browse the repository at this point in the history
  • Loading branch information
lysnikolaou committed Feb 25, 2025
1 parent 6d1b01c commit 95de33c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion yarl/_quoting_c.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ cdef str QS = '+&=;'

DEF BUF_SIZE = 8 * 1024 # 8KiB
cdef char BUFFER[BUF_SIZE]
cdef bint IS_GIL_DISABLED = sysconfig.get_config_var("Py_GIL_DISABLED")

cdef inline Py_UCS4 _to_hex(uint8_t v) noexcept:
if v < 10:
Expand Down Expand Up @@ -93,7 +94,8 @@ cdef struct Writer:

cdef inline void _init_writer(Writer* writer):
cdef char *buf
if sysconfig.get_config_var("Py_GIL_DISABLED"):
if IS_GIL_DISABLED:
print("Calling malloc...")
buf = <char *> PyMem_Malloc(BUF_SIZE)
if buf == NULL:
PyErr_NoMemory()
Expand Down

0 comments on commit 95de33c

Please sign in to comment.