Skip to content

Commit c2539a8

Browse files
committed
chore: cleanup comments
1 parent 905c36c commit c2539a8

17 files changed

Lines changed: 0 additions & 198 deletions

src/jsonlt/_state.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ def compute_logical_state(
4848
state: dict[Key, JSONObject] = {}
4949

5050
for obj in operations:
51-
# Extract the key from the operation
5251
key = extract_key(obj, key_specifier)
5352

5453
# Determine operation type and apply

src/jsonlt/_table.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -160,21 +160,16 @@ def _load(self, caller_key: "KeySpecifier | None" = None) -> None:
160160
InvalidKeyError: If the key specifier is invalid or mismatches
161161
the header, or if the file has operations but no key specifier.
162162
"""
163-
# Check if file exists - if not, treat as empty table
164163
if not self._path.exists():
165164
self._load_empty_table(caller_key)
166165
return
167166

168-
# Read and parse the file
169167
header, operations = read_table_file(
170168
self._path, max_file_size=self._max_file_size
171169
)
172170
self._header = header
173-
174-
# Track file stats for auto-reload
175171
self._update_file_stats()
176172

177-
# Resolve which key specifier to use
178173
resolved_key = self._resolve_key_specifier(caller_key, header, operations)
179174
if resolved_key is None:
180175
# Empty file with no key specifier - OK for now
@@ -185,7 +180,6 @@ def _load(self, caller_key: "KeySpecifier | None" = None) -> None:
185180

186181
self._key_specifier = resolved_key
187182

188-
# Compute logical state if we have operations
189183
if operations:
190184
self._state = compute_logical_state(operations, self._key_specifier)
191185
else:
@@ -205,12 +199,10 @@ def _load_from_content(self, content: bytes) -> None:
205199
ParseError: If the content contains invalid data.
206200
"""
207201
if not content:
208-
# Empty content - nothing to load
209202
self._state = {}
210203
self._cached_sorted_keys = None
211204
return
212205

213-
# Parse the content
214206
header, operations = parse_table_content(content)
215207
self._header = header
216208

@@ -223,7 +215,6 @@ def _load_from_content(self, content: bytes) -> None:
223215

224216
self._key_specifier = resolved_key
225217

226-
# Compute logical state if we have operations
227218
if operations:
228219
self._state = compute_logical_state(operations, self._key_specifier)
229220
else:
@@ -395,8 +386,6 @@ def reload(self) -> None:
395386
self._load()
396387
self._cached_sorted_keys = None
397388

398-
# --- Write Operations ---
399-
400389
def _require_key_specifier(self) -> KeySpecifier:
401390
"""Return key specifier or raise InvalidKeyError if not set."""
402391
if self._key_specifier is None:
@@ -525,14 +514,11 @@ def delete(self, key: Key) -> bool:
525514
# Validate key arity matches specifier
526515
validate_key_arity(key, key_specifier)
527516

528-
# Validate key length
529517
validate_key_length(key)
530518

531-
# Build tombstone
532519
tombstone = build_tombstone(key, key_specifier)
533520
serialized = serialize_json(tombstone)
534521

535-
# Write under lock - returns whether key existed (checked after reload)
536522
return self._write_with_lock(serialized, key, None)
537523

538524
def clear(self) -> None:

src/jsonlt/_transaction.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,9 @@ def put(self, record: "JSONObject") -> None:
149149
"""
150150
self._require_active()
151151

152-
# Check for unpaired surrogates in all strings
153152
validate_no_surrogates(record)
154-
155-
# Validate record structure (missing fields, invalid key types, $ fields)
156153
validate_record(record, self._key_specifier)
157154

158-
# Extract and validate key
159155
key = extract_key(record, self._key_specifier)
160156
validate_key_length(key)
161157

@@ -169,12 +165,10 @@ def put(self, record: "JSONObject") -> None:
169165
# Cache serialized form before deep copy (record hasn't been modified)
170166
self._buffer_serialized[key] = serialized
171167

172-
# Buffer the update (only keep latest value per key)
173168
record_copy = copy.deepcopy(record)
174169
self._buffer_updates[key] = record_copy
175170
self._written_keys.add(key)
176171

177-
# Update snapshot
178172
self._snapshot[key] = record_copy
179173
self._cached_sorted_keys = None
180174

@@ -196,21 +190,15 @@ def delete(self, key: Key) -> bool:
196190
"""
197191
self._require_active()
198192

199-
# Validate key arity matches specifier
200193
validate_key_arity(key, self._key_specifier)
201-
202-
# Validate key length
203194
validate_key_length(key)
204195

205-
# Check if key exists in snapshot
206196
existed = key in self._snapshot
207197

208-
# Buffer the delete (only keep latest state per key)
209198
self._buffer_updates[key] = None
210199
_ = self._buffer_serialized.pop(key, None)
211200
self._written_keys.add(key)
212201

213-
# Update snapshot
214202
if existed:
215203
del self._snapshot[key]
216204
self._cached_sorted_keys = None

tests/benchmarks/test_bench_memory.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
"""Memory profiling benchmarks for JSONLT.
2-
3-
This module contains memory usage benchmarks using pytest-memray to ensure
4-
memory consumption stays within expected bounds.
5-
"""
6-
71
import sys
82
from typing import TYPE_CHECKING
93

@@ -26,8 +20,6 @@
2620

2721

2822
class TestMemoryLoad:
29-
"""Memory benchmarks for loading tables."""
30-
3123
@pytest.mark.limit_memory("10 MB")
3224
def test_load_1k_small_records(self, tmp_path: "Path") -> None:
3325
records = generate_records("string", "small", 1000)
@@ -88,8 +80,6 @@ def test_load_1k_large_records(self, tmp_path: "Path") -> None:
8880

8981

9082
class TestMemoryLoadKeyTypes:
91-
"""Memory benchmarks for loading with different key types."""
92-
9383
@pytest.mark.limit_memory("10 MB")
9484
def test_load_1k_integer_keys(self, tmp_path: "Path") -> None:
9585
records = generate_records("integer", "small", 1000)
@@ -130,8 +120,6 @@ def test_load_10k_tuple_keys(self, tmp_path: "Path") -> None:
130120

131121

132122
class TestMemoryRead:
133-
"""Memory benchmarks for read operations."""
134-
135123
@pytest.mark.limit_memory("15 MB")
136124
def test_all_1k_records(self, tmp_path: "Path") -> None:
137125
records = generate_records("string", "small", 1000)
@@ -175,8 +163,6 @@ def test_keys_1k_records(self, tmp_path: "Path") -> None:
175163

176164

177165
class TestMemoryWrite:
178-
"""Memory benchmarks for write operations."""
179-
180166
@pytest.mark.limit_memory("15 MB")
181167
def test_put_to_1k_table(self, tmp_path: "Path") -> None:
182168
records = generate_records("string", "small", 1000)

0 commit comments

Comments
 (0)