Skip to content

Commit 235f69e

Browse files
chore: hoist lazy import struct to module level in tuples.py
The V1 params tuple encode/decode paths had `import struct` inside function bodies, unlike every other module that imports struct at the top level. Hoisted to module level for consistency and to avoid the sys.modules lookup on every V1 call. Closes #135 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 21d233c commit 235f69e

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

src/dqlitewire/tuples.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- Row tuples: column types header, then values
66
"""
77

8+
import struct
89
from collections.abc import Sequence
910
from enum import Enum
1011
from typing import Any
@@ -57,8 +58,6 @@ def encode_params_tuple(params: Sequence[Any], schema: int = 0, buffer_offset: i
5758
header = bytearray()
5859
if schema == 1:
5960
# V1: uint32 count
60-
import struct
61-
6261
header.extend(struct.pack("<I", len(params)))
6362
else:
6463
# V0: uint8 count
@@ -120,8 +119,6 @@ def decode_params_tuple(
120119
count_size: int
121120
if count is None:
122121
if schema == 1:
123-
import struct
124-
125122
count = struct.unpack("<I", data[:4])[0]
126123
count_size = 4
127124
else:

0 commit comments

Comments
 (0)