fastsimdjson 1.0.0__tar.gz → 2.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. {fastsimdjson-1.0.0/src/fastsimdjson.egg-info → fastsimdjson-2.0.0}/PKG-INFO +54 -2
  2. {fastsimdjson-1.0.0 → fastsimdjson-2.0.0}/README.md +53 -1
  3. {fastsimdjson-1.0.0 → fastsimdjson-2.0.0}/pyproject.toml +15 -1
  4. {fastsimdjson-1.0.0 → fastsimdjson-2.0.0}/src/fastsimdjson.cpp +605 -33
  5. {fastsimdjson-1.0.0 → fastsimdjson-2.0.0/src/fastsimdjson.egg-info}/PKG-INFO +54 -2
  6. {fastsimdjson-1.0.0 → fastsimdjson-2.0.0}/src/fastsimdjson.egg-info/SOURCES.txt +1 -0
  7. fastsimdjson-2.0.0/tests/conftest.py +21 -0
  8. {fastsimdjson-1.0.0 → fastsimdjson-2.0.0}/tests/test_dumps.py +10 -2
  9. {fastsimdjson-1.0.0 → fastsimdjson-2.0.0}/tests/test_lazy.py +1 -0
  10. {fastsimdjson-1.0.0 → fastsimdjson-2.0.0}/tests/test_loads.py +5 -0
  11. {fastsimdjson-1.0.0 → fastsimdjson-2.0.0}/tests/test_msgpack.py +1 -0
  12. {fastsimdjson-1.0.0 → fastsimdjson-2.0.0}/tests/test_stream.py +209 -0
  13. {fastsimdjson-1.0.0 → fastsimdjson-2.0.0}/tests/test_typed.py +4 -1
  14. {fastsimdjson-1.0.0 → fastsimdjson-2.0.0}/MANIFEST.in +0 -0
  15. {fastsimdjson-1.0.0 → fastsimdjson-2.0.0}/setup.cfg +0 -0
  16. {fastsimdjson-1.0.0 → fastsimdjson-2.0.0}/setup.py +0 -0
  17. {fastsimdjson-1.0.0 → fastsimdjson-2.0.0}/src/fastsimdjson.egg-info/dependency_links.txt +0 -0
  18. {fastsimdjson-1.0.0 → fastsimdjson-2.0.0}/src/fastsimdjson.egg-info/requires.txt +0 -0
  19. {fastsimdjson-1.0.0 → fastsimdjson-2.0.0}/src/fastsimdjson.egg-info/top_level.txt +0 -0
  20. {fastsimdjson-1.0.0 → fastsimdjson-2.0.0}/src/typed.h +0 -0
  21. {fastsimdjson-1.0.0 → fastsimdjson-2.0.0}/tests/test_arrow.py +0 -0
  22. {fastsimdjson-1.0.0 → fastsimdjson-2.0.0}/tests/test_files.py +0 -0
  23. {fastsimdjson-1.0.0 → fastsimdjson-2.0.0}/tests/test_minify.py +0 -0
  24. {fastsimdjson-1.0.0 → fastsimdjson-2.0.0}/vendor/simdjson.cpp +0 -0
  25. {fastsimdjson-1.0.0 → fastsimdjson-2.0.0}/vendor/simdjson.h +0 -0
  26. {fastsimdjson-1.0.0 → fastsimdjson-2.0.0}/vendor/simdjson_arrow-LICENSE +0 -0
  27. {fastsimdjson-1.0.0 → fastsimdjson-2.0.0}/vendor/simdjson_arrow.cpp +0 -0
  28. {fastsimdjson-1.0.0 → fastsimdjson-2.0.0}/vendor/simdjson_arrow.h +0 -0
  29. {fastsimdjson-1.0.0 → fastsimdjson-2.0.0}/vendor/simdjson_msgpack-LICENSE +0 -0
  30. {fastsimdjson-1.0.0 → fastsimdjson-2.0.0}/vendor/simdjson_msgpack.cpp +0 -0
  31. {fastsimdjson-1.0.0 → fastsimdjson-2.0.0}/vendor/simdjson_msgpack.h +0 -0
  32. {fastsimdjson-1.0.0 → fastsimdjson-2.0.0}/vendor/simdutf.cpp +0 -0
  33. {fastsimdjson-1.0.0 → fastsimdjson-2.0.0}/vendor/simdutf.h +0 -0
  34. {fastsimdjson-1.0.0 → fastsimdjson-2.0.0}/vendor/simdutf_c.h +0 -0
  35. {fastsimdjson-1.0.0 → fastsimdjson-2.0.0}/vendor/zmij-LICENSE +0 -0
  36. {fastsimdjson-1.0.0 → fastsimdjson-2.0.0}/vendor/zmij.h +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastsimdjson
3
- Version: 1.0.0
3
+ Version: 2.0.0
4
4
  Summary: Fast JSON parsing for Python, built on simdjson
5
5
  Author-email: Daniel Lemire <daniel@lemire.me>
6
6
  License-Expression: Apache-2.0
@@ -103,6 +103,17 @@ uv pip install fastsimdjson # in a uv project: uv add fastsimdjson
103
103
  Wheels are available for Linux, macOS and Windows, for Python 3.10 to 3.15,
104
104
  including free-threaded Python 3.14 and 3.15.
105
105
 
106
+ Wheels are also available for Pyodide (WebAssembly, in the browser or in
107
+ Node), for Python 3.13 to 3.15:
108
+
109
+ ```python
110
+ import micropip
111
+ await micropip.install("fastsimdjson")
112
+ ```
113
+
114
+ Under Pyodide, Python cannot start threads: `threads=` runs on the calling
115
+ thread.
116
+
106
117
  ## Usage
107
118
 
108
119
  ### `loads`: the whole document
@@ -352,6 +363,18 @@ separated:
352
363
  | `"comma"` | documents separated by commas: `{...}, {...}` (simdjson also accepts white space between them) |
353
364
  | `"array"` | the elements of one array: `[{...}, {...}]` |
354
365
 
366
+ To read a file without copying it, map it in memory:
367
+
368
+ ```python
369
+ import mmap
370
+ with open("log.ndjson", "rb") as f, mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ) as m:
371
+ names = fastsimdjson.map_many(fn, memoryview(m), threads=64)
372
+ ```
373
+
374
+ A `memoryview` of `bytes`, or of a file mapped with `mmap.ACCESS_READ` (as
375
+ here), is read in place, and the mapped file must not change meanwhile;
376
+ other buffers (a `bytearray`, a view of a writable mmap) are copied first.
377
+
355
378
  simdjson parses the input in batches (`batch_size`, 1 MB by default); a
356
379
  larger document is handled automatically. In every format, documents that
357
380
  simdjson rejects are handled as in `loads`: a document that `json` accepts is
@@ -397,6 +420,19 @@ document, and the Python objects of all of them, to the calling thread.
397
420
  With the GIL (the default build of Python), the calling thread does all the
398
421
  work: `threads` has no effect on speed.
399
422
 
423
+ With `drop_none=True`, `map_many` leaves out the results that are `None`:
424
+ when `fn` keeps only a few documents, the threads do not build a list
425
+ entry for each of the others, and the calling thread has fewer to collect.
426
+
427
+ ```python
428
+ def starred(event):
429
+ kind, repo = event
430
+ return repo if kind == "WatchEvent" else None
431
+
432
+ names = fastsimdjson.map_many(starred, data, threads=64, drop_none=True,
433
+ fields=["/type", "/repo/name"])
434
+ ```
435
+
400
436
  ### Only some fields: `fields=`
401
437
 
402
438
  When you need a few values from each document, `fields` extracts them
@@ -424,6 +460,18 @@ missing key, an index past the end, or a step into a scalar) gives
424
460
  As with `at_pointer`, a key that appears twice in an object refers to its
425
461
  first occurrence. `fields` cannot be combined with `lazy=True`.
426
462
 
463
+ With the formats `"whitespace"` and `"lines"`, `fields` reads the documents
464
+ with simdjson's On-Demand API: the top level of each document, the keys on
465
+ the way to the pointers and the values found there are read and validated,
466
+ so a malformed or incomplete document is still an error. The values that no
467
+ pointer reaches are skipped without being checked, so an invalid value
468
+ elsewhere in a document (`{"a": 1, "b": tru}` with `fields="/a"`) goes
469
+ unnoticed. A value that is read is handled as without `fields`: an error
470
+ raises `JSONDecodeError`, and a document that only `json` accepts is decoded
471
+ by `json`. The whole documents are parsed (and validated) with the other
472
+ formats, and when a pointer is `""` or leads into the value of another
473
+ pointer (`["/a", "/a/b"]`).
474
+
427
475
  On 7.6 GB of GitHub events, `map_many` with three fields ran at 2.2 GB/s on
428
476
  one core of an Intel Xeon Gold 6548N, against 1.8 GB/s with lazy views
429
477
  (`lazy=True`). With 64 threads (free-threaded Python 3.14.10t), it ran at
@@ -571,7 +619,11 @@ could be changed by another thread while we read it, so it is copied first:
571
619
  always by `loads_many`, `parse_many` and `map_many` (the iterator outlives
572
620
  the call) and by `loads_arrow`, `json_to_msgpack` and `msgpack_to_json`
573
621
  (which release the GIL), and only on a free-threaded build by `loads` and
574
- `parse`. Likewise, on a free-threaded build, `dumps` and `dumpb` hold
622
+ `parse`. The exception: `loads_many`, `parse_many` and `map_many` read a
623
+ read-only, contiguous `memoryview` of `bytes`, or of a file mapped with
624
+ `mmap.ACCESS_READ`, in place (the file must not change meanwhile). Other
625
+ read-only views (`memoryview(bytearray).toreadonly()`, a read-only view of a
626
+ writable mmap) are copied, since what they show can still change. Likewise, on a free-threaded build, `dumps` and `dumpb` hold
575
627
  references to the items of the containers they serialize.
576
628
 
577
629
  ### `release`
@@ -61,6 +61,17 @@ uv pip install fastsimdjson # in a uv project: uv add fastsimdjson
61
61
  Wheels are available for Linux, macOS and Windows, for Python 3.10 to 3.15,
62
62
  including free-threaded Python 3.14 and 3.15.
63
63
 
64
+ Wheels are also available for Pyodide (WebAssembly, in the browser or in
65
+ Node), for Python 3.13 to 3.15:
66
+
67
+ ```python
68
+ import micropip
69
+ await micropip.install("fastsimdjson")
70
+ ```
71
+
72
+ Under Pyodide, Python cannot start threads: `threads=` runs on the calling
73
+ thread.
74
+
64
75
  ## Usage
65
76
 
66
77
  ### `loads`: the whole document
@@ -310,6 +321,18 @@ separated:
310
321
  | `"comma"` | documents separated by commas: `{...}, {...}` (simdjson also accepts white space between them) |
311
322
  | `"array"` | the elements of one array: `[{...}, {...}]` |
312
323
 
324
+ To read a file without copying it, map it in memory:
325
+
326
+ ```python
327
+ import mmap
328
+ with open("log.ndjson", "rb") as f, mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ) as m:
329
+ names = fastsimdjson.map_many(fn, memoryview(m), threads=64)
330
+ ```
331
+
332
+ A `memoryview` of `bytes`, or of a file mapped with `mmap.ACCESS_READ` (as
333
+ here), is read in place, and the mapped file must not change meanwhile;
334
+ other buffers (a `bytearray`, a view of a writable mmap) are copied first.
335
+
313
336
  simdjson parses the input in batches (`batch_size`, 1 MB by default); a
314
337
  larger document is handled automatically. In every format, documents that
315
338
  simdjson rejects are handled as in `loads`: a document that `json` accepts is
@@ -355,6 +378,19 @@ document, and the Python objects of all of them, to the calling thread.
355
378
  With the GIL (the default build of Python), the calling thread does all the
356
379
  work: `threads` has no effect on speed.
357
380
 
381
+ With `drop_none=True`, `map_many` leaves out the results that are `None`:
382
+ when `fn` keeps only a few documents, the threads do not build a list
383
+ entry for each of the others, and the calling thread has fewer to collect.
384
+
385
+ ```python
386
+ def starred(event):
387
+ kind, repo = event
388
+ return repo if kind == "WatchEvent" else None
389
+
390
+ names = fastsimdjson.map_many(starred, data, threads=64, drop_none=True,
391
+ fields=["/type", "/repo/name"])
392
+ ```
393
+
358
394
  ### Only some fields: `fields=`
359
395
 
360
396
  When you need a few values from each document, `fields` extracts them
@@ -382,6 +418,18 @@ missing key, an index past the end, or a step into a scalar) gives
382
418
  As with `at_pointer`, a key that appears twice in an object refers to its
383
419
  first occurrence. `fields` cannot be combined with `lazy=True`.
384
420
 
421
+ With the formats `"whitespace"` and `"lines"`, `fields` reads the documents
422
+ with simdjson's On-Demand API: the top level of each document, the keys on
423
+ the way to the pointers and the values found there are read and validated,
424
+ so a malformed or incomplete document is still an error. The values that no
425
+ pointer reaches are skipped without being checked, so an invalid value
426
+ elsewhere in a document (`{"a": 1, "b": tru}` with `fields="/a"`) goes
427
+ unnoticed. A value that is read is handled as without `fields`: an error
428
+ raises `JSONDecodeError`, and a document that only `json` accepts is decoded
429
+ by `json`. The whole documents are parsed (and validated) with the other
430
+ formats, and when a pointer is `""` or leads into the value of another
431
+ pointer (`["/a", "/a/b"]`).
432
+
385
433
  On 7.6 GB of GitHub events, `map_many` with three fields ran at 2.2 GB/s on
386
434
  one core of an Intel Xeon Gold 6548N, against 1.8 GB/s with lazy views
387
435
  (`lazy=True`). With 64 threads (free-threaded Python 3.14.10t), it ran at
@@ -529,7 +577,11 @@ could be changed by another thread while we read it, so it is copied first:
529
577
  always by `loads_many`, `parse_many` and `map_many` (the iterator outlives
530
578
  the call) and by `loads_arrow`, `json_to_msgpack` and `msgpack_to_json`
531
579
  (which release the GIL), and only on a free-threaded build by `loads` and
532
- `parse`. Likewise, on a free-threaded build, `dumps` and `dumpb` hold
580
+ `parse`. The exception: `loads_many`, `parse_many` and `map_many` read a
581
+ read-only, contiguous `memoryview` of `bytes`, or of a file mapped with
582
+ `mmap.ACCESS_READ`, in place (the file must not change meanwhile). Other
583
+ read-only views (`memoryview(bytearray).toreadonly()`, a read-only view of a
584
+ writable mmap) are copied, since what they show can still change. Likewise, on a free-threaded build, `dumps` and `dumpb` hold
533
585
  references to the items of the containers they serialize.
534
586
 
535
587
  ### `release`
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "fastsimdjson"
7
- version = "1.0.0"
7
+ version = "2.0.0"
8
8
  description = "Fast JSON parsing for Python, built on simdjson"
9
9
  readme = "README.md"
10
10
  authors = [
@@ -51,6 +51,20 @@ archs = ["x86_64", "universal2", "arm64"]
51
51
  # are provided separately in the CI matrix, so each builds natively).
52
52
  archs = ["native"]
53
53
 
54
+ [tool.cibuildwheel.pyodide]
55
+ # WebAssembly wheels, one per Pyodide ABI (cp313: Pyodide 0.28 and 0.29;
56
+ # cp314: Pyodide 314; cp315). In a Pyodide venv, the pytest script starts
57
+ # with a shebang to a shell script, which macOS cannot run: python -m pytest.
58
+ test-command = "python -m pytest {project}/tests -q"
59
+
54
60
  [tool.cibuildwheel.windows]
55
61
  # Build for 64-bit Windows (32-bit is rarely needed nowadays)
56
62
  archs = ["AMD64"]
63
+
64
+ [tool.pyodide.build]
65
+ # Pyodide's default flags, but -O3 where they end with -Oz (size): dumps and
66
+ # dumpb are up to twice as fast, loads up to 15%. ($(...) variables are not
67
+ # expanded here, so the flags are spelled out.)
68
+ cflags = "-g0 -fPIC -fwasm-exceptions -sSUPPORT_LONGJMP=wasm -O3"
69
+ cxxflags = "-g0 -fPIC -fwasm-exceptions -sSUPPORT_LONGJMP=wasm -O3"
70
+ ldflags = "-g0 -fwasm-exceptions -sSUPPORT_LONGJMP=wasm -s SIDE_MODULE=1 -O3"