@@ -55,23 +55,22 @@ cdef extern from *:
5555# theoretical maximum is ~2 GiB. We use 256 MiB as a practical upper
5656# bound (matching the server's default frame size limit) to avoid
5757# accidentally allocating multi-GiB buffers on corrupt headers.
58- DEF MAX_DECOMPRESSED_LENGTH = 268435456 # 256 MiB
58+ cdef enum :
59+ MAX_DECOMPRESSED_LENGTH = 268435456 # 256 MiB
5960
6061# LZ4_MAX_INPUT_SIZE from lz4.h — the LZ4 C API uses C int (32-bit
6162# signed) for sizes, so we must reject Python bytes objects that
6263# exceed this before casting Py_ssize_t down to int.
63- DEF LZ4_MAX_INPUT_SIZE = 0x7E000000 # 2 113 929 216 bytes
64+ cdef enum :
65+ LZ4_MAX_INPUT_SIZE = 0x7E000000 # 2 113 929 216 bytes
6466
6567# Maximum LZ4_compressBound value for which we use a fixed-size buffer on
66- # the C stack instead of malloc. 128 KiB is well within the default
67- # 8 MiB thread stack size (POSIX) / 1 MiB (Windows) and covers CQL frames
68- # up to ~127 KiB uncompressed — the vast majority of real traffic. Larger
69- # frames fall back to heap allocation. A plain fixed-size array is used
70- # (rather than alloca()) because alloca() is declared in <alloca.h>, which
71- # does not exist on Windows/MSVC (it ships _alloca() in <malloc.h> instead
72- # with subtly different semantics) — a fixed-size array avoids that
73- # platform split entirely while remaining just as cheap.
74- DEF STACK_ALLOC_THRESHOLD = 131072 # 128 KiB
68+ # the C stack instead of malloc. 16 KiB covers common CQL frames while
69+ # keeping the per-call stack frame small. Larger frames fall back to heap
70+ # allocation. A plain fixed-size array is used instead of alloca(), which
71+ # is not portable across Windows/MSVC and POSIX.
72+ cdef enum :
73+ STACK_ALLOC_THRESHOLD = 16384 # 16 KiB
7574
7675
7776cdef extern from " lz4.h" :
0 commit comments