dotted-notation 0.56.2__tar.gz → 0.57.1__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 (51) hide show
  1. {dotted_notation-0.56.2 → dotted_notation-0.57.1}/CHANGELOG.md +52 -0
  2. {dotted_notation-0.56.2/dotted_notation.egg-info → dotted_notation-0.57.1}/PKG-INFO +147 -22
  3. {dotted_notation-0.56.2 → dotted_notation-0.57.1}/README.md +146 -21
  4. {dotted_notation-0.56.2 → dotted_notation-0.57.1}/dotted/__init__.py +18 -10
  5. {dotted_notation-0.56.2 → dotted_notation-0.57.1}/dotted/access.py +78 -3
  6. {dotted_notation-0.56.2 → dotted_notation-0.57.1}/dotted/api.py +117 -53
  7. {dotted_notation-0.56.2 → dotted_notation-0.57.1}/dotted/base.pxd +1 -0
  8. {dotted_notation-0.56.2 → dotted_notation-0.57.1}/dotted/base.py +30 -5
  9. {dotted_notation-0.56.2 → dotted_notation-0.57.1}/dotted/engine.pxd +1 -1
  10. {dotted_notation-0.56.2 → dotted_notation-0.57.1}/dotted/engine.py +12 -9
  11. {dotted_notation-0.56.2 → dotted_notation-0.57.1}/dotted/filters.py +27 -7
  12. {dotted_notation-0.56.2 → dotted_notation-0.57.1}/dotted/results.py +1 -5
  13. {dotted_notation-0.56.2 → dotted_notation-0.57.1}/dotted/translators/core.py +17 -3
  14. {dotted_notation-0.56.2 → dotted_notation-0.57.1}/dotted/translators/spark.py +46 -4
  15. {dotted_notation-0.56.2 → dotted_notation-0.57.1}/dotted/translators/spark_pyspark.py +90 -4
  16. {dotted_notation-0.56.2 → dotted_notation-0.57.1}/dotted/utils.py +71 -1
  17. {dotted_notation-0.56.2 → dotted_notation-0.57.1}/dotted/utypes.py +3 -0
  18. {dotted_notation-0.56.2 → dotted_notation-0.57.1}/dotted/wrappers.py +21 -27
  19. {dotted_notation-0.56.2 → dotted_notation-0.57.1/dotted_notation.egg-info}/PKG-INFO +147 -22
  20. {dotted_notation-0.56.2 → dotted_notation-0.57.1}/pyproject.toml +2 -2
  21. {dotted_notation-0.56.2 → dotted_notation-0.57.1}/LICENSE +0 -0
  22. {dotted_notation-0.56.2 → dotted_notation-0.57.1}/MANIFEST.in +0 -0
  23. {dotted_notation-0.56.2 → dotted_notation-0.57.1}/dotted/__main__.py +0 -0
  24. {dotted_notation-0.56.2 → dotted_notation-0.57.1}/dotted/access.pxd +0 -0
  25. {dotted_notation-0.56.2 → dotted_notation-0.57.1}/dotted/cli/__init__.py +0 -0
  26. {dotted_notation-0.56.2 → dotted_notation-0.57.1}/dotted/cli/_compat.py +0 -0
  27. {dotted_notation-0.56.2 → dotted_notation-0.57.1}/dotted/cli/formats.py +0 -0
  28. {dotted_notation-0.56.2 → dotted_notation-0.57.1}/dotted/cli/main.py +0 -0
  29. {dotted_notation-0.56.2 → dotted_notation-0.57.1}/dotted/containers.py +0 -0
  30. {dotted_notation-0.56.2 → dotted_notation-0.57.1}/dotted/filters.pxd +0 -0
  31. {dotted_notation-0.56.2 → dotted_notation-0.57.1}/dotted/grammar.py +0 -0
  32. {dotted_notation-0.56.2 → dotted_notation-0.57.1}/dotted/groups.pxd +0 -0
  33. {dotted_notation-0.56.2 → dotted_notation-0.57.1}/dotted/groups.py +0 -0
  34. {dotted_notation-0.56.2 → dotted_notation-0.57.1}/dotted/matchers.pxd +0 -0
  35. {dotted_notation-0.56.2 → dotted_notation-0.57.1}/dotted/matchers.py +0 -0
  36. {dotted_notation-0.56.2 → dotted_notation-0.57.1}/dotted/native.py +0 -0
  37. {dotted_notation-0.56.2 → dotted_notation-0.57.1}/dotted/predicates.py +0 -0
  38. {dotted_notation-0.56.2 → dotted_notation-0.57.1}/dotted/recursive.pxd +0 -0
  39. {dotted_notation-0.56.2 → dotted_notation-0.57.1}/dotted/recursive.py +0 -0
  40. {dotted_notation-0.56.2 → dotted_notation-0.57.1}/dotted/transforms.py +0 -0
  41. {dotted_notation-0.56.2 → dotted_notation-0.57.1}/dotted/translators/__init__.py +0 -0
  42. {dotted_notation-0.56.2 → dotted_notation-0.57.1}/dotted/translators/sql.py +0 -0
  43. {dotted_notation-0.56.2 → dotted_notation-0.57.1}/dotted/translators/sql_pg.py +0 -0
  44. {dotted_notation-0.56.2 → dotted_notation-0.57.1}/dotted/wrappers.pxd +0 -0
  45. {dotted_notation-0.56.2 → dotted_notation-0.57.1}/dotted_notation.egg-info/SOURCES.txt +0 -0
  46. {dotted_notation-0.56.2 → dotted_notation-0.57.1}/dotted_notation.egg-info/dependency_links.txt +0 -0
  47. {dotted_notation-0.56.2 → dotted_notation-0.57.1}/dotted_notation.egg-info/entry_points.txt +0 -0
  48. {dotted_notation-0.56.2 → dotted_notation-0.57.1}/dotted_notation.egg-info/requires.txt +0 -0
  49. {dotted_notation-0.56.2 → dotted_notation-0.57.1}/dotted_notation.egg-info/top_level.txt +0 -0
  50. {dotted_notation-0.56.2 → dotted_notation-0.57.1}/setup.cfg +0 -0
  51. {dotted_notation-0.56.2 → dotted_notation-0.57.1}/setup.py +0 -0
@@ -3,6 +3,58 @@
3
3
  All notable changes to `dotted` are recorded here. Versions prior to
4
4
  the ones listed are omitted — browse git history for earlier entries.
5
5
 
6
+ ## [0.57.1]
7
+
8
+ ### Added
9
+ - `sparkize` reads a path under a `Column` the caller holds: a
10
+ substitution at a read's head, `$(item).id`, is bound in `build` to a
11
+ Column, which the path then reads from, or to a column's name.
12
+ `r.typed(column, dtype)` (`dotted.translators.spark.typed`) carries
13
+ the type of a Column no session resolves, a higher-order function's
14
+ lambda argument, and works for any Column binding (#83).
15
+
16
+ ### Fixed
17
+ - `sparkize`: a `Column` bound at a path's head with `bindings=` is read
18
+ from; it was taken for a column's name and read NULL. A Column where
19
+ a name is needed (a write's column, a table, a filter key) raises
20
+ (#83).
21
+
22
+ ## [0.57.0]
23
+
24
+ ### Added
25
+ - Streaming reads: `iget`, `ipluck` and `iexpand` read through a one-shot
26
+ iterator (a generator, a `map`, a cursor). A pattern iterates what it
27
+ reads and yields one match at a time, drawing from the iterator only as
28
+ far as it is asked: `iget({'rows': gen}, 'rows[*&x=1].y')`. A dict-like
29
+ is read through its own `items()`, a sequence or iterator through its
30
+ `__iter__`. A slice of an iterator is an `islice` of it and a slice
31
+ filter of one a generator, read with a following `[*]`. An index, or a
32
+ slice from the end, does not match an iterator and does not draw from
33
+ it. An iterator is read once: a path that reaches it twice finds it
34
+ empty the second time.
35
+ - `iget_multi`, `ipluck_multi` and `iexpand_multi`, the streaming forms of
36
+ `get_multi`, `pluck_multi` and `expand_multi`. `iget_multi` is flat:
37
+ every match of every path in one stream.
38
+ - `iter` as a type restriction name, a one-shot iterator: `*:!iter`.
39
+
40
+ ### Changed (breaking)
41
+ - `unique=False` replaces `duplicates=False` on `pluck`, `expand`, their
42
+ `i` and `_multi` forms: every match is yielded, and
43
+ `unique=True` gives each path once. `pluck` and `expand` no longer
44
+ dedup by default. `duplicates=` is removed.
45
+ - `iget`, `ipluck` and `iexpand` read through an iterator, which yielded
46
+ nothing before. `get`, `has`, `pluck`, `expand` and the writes are
47
+ unchanged, and never draw from one.
48
+ - `walk` and `walk_multi` are removed: call `ipluck` and `ipluck_multi`.
49
+
50
+ ### Fixed
51
+ - An iterator is no longer taken for a set: a set pattern in a value
52
+ guard no longer matches, and so consumes, a generator.
53
+ - An OR filter keeps an object that sits at several positions of a
54
+ list at each of them. It tracked matches by identity, so
55
+ `get([d, d], '[*&x=1,x=2]')` gave `d` once, the slice filter
56
+ `[x=1,x=2]` likewise, and `remove` left the repeats behind.
57
+
6
58
  ## [0.56.2]
7
59
 
8
60
  ### Added
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dotted_notation
3
- Version: 0.56.2
3
+ Version: 0.57.1
4
4
  Summary: Dotted notation for safe nested data traversal with optional chaining, pattern matching, and transforms
5
5
  Author-email: Frey Waid <logophage1@gmail.com>
6
6
  License-Expression: MIT
@@ -101,6 +101,7 @@ For faster `mutable=False` updates and removes, install the
101
101
  - [Breaking Changes](#breaking-changes)
102
102
  - [API](#api)
103
103
  - [Get](#get)
104
+ - [Streaming reads](#streaming-reads)
104
105
  - [Update](#update)
105
106
  - [Remove](#remove)
106
107
  - [Match](#match)
@@ -112,7 +113,7 @@ For faster `mutable=False` updates and removes, install the
112
113
  - [Mutable](#mutable)
113
114
  - [Setdefault](#setdefault)
114
115
  - [Pluck](#pluck)
115
- - [Walk](#walk)
116
+ - [Ipluck](#ipluck)
116
117
  - [Unpack](#unpack)
117
118
  - [Pack](#pack)
118
119
  - [Keys, Values, Items](#keys-values-items)
@@ -275,10 +276,24 @@ Several Python libraries handle nested data access. Here's how dotted compares:
275
276
  - **String/bytes glob patterns**—match by prefix, suffix, or substring: `*="user_"...`, `*=b"header"...b"footer"`
276
277
  - **Value groups**—disjunction over filter values: `*=(1, 2, 3)`, `[*&status=("active", "pending")]`
277
278
  - **Strict mode**—enforce type separation: `[0]` only matches lists, `.key` only matches dicts
279
+ - **Streaming reads**—`iget`, `ipluck` and `iexpand` read through generators and other one-shot iterators, one match at a time: `rows[*&active=True].id` over a cursor
278
280
 
279
281
  <a id="breaking-changes"></a>
280
282
  ## Breaking Changes
281
283
 
284
+ ### v0.57.0
285
+ - **`pluck` and `expand` no longer dedup by default.** `unique=False`
286
+ replaces `duplicates=False` on `pluck`, `expand` and their `i` and `_multi`
287
+ forms: a path a pattern reaches twice is yielded twice.
288
+ Pass `unique=True` for each path once; `duplicates=` is gone and raises
289
+ `TypeError`. See [Pluck](#pluck).
290
+ - **`iget`, `ipluck` and `iexpand` are streaming reads.** A pattern
291
+ iterates what it reads, so they read through a one-shot iterator, which
292
+ yielded nothing before. See [Streaming reads](#streaming-reads).
293
+ - **`walk` and `walk_multi` are removed.** They were other names for
294
+ `ipluck` and `pluck_multi`; call `ipluck` and `ipluck_multi`. See
295
+ [Ipluck](#ipluck).
296
+
282
297
  ### v0.56.0
283
298
  - **`sparkize`'s `build` takes the DataFrame's schema.** A path reads
284
299
  each node by its type, so `r.build(fragment, schema=df.schema)`;
@@ -292,7 +307,7 @@ Several Python libraries handle nested data access. Here's how dotted compares:
292
307
  - **`walk` dedups.** It is now `ipluck`, and `walk_multi` is `pluck_multi`,
293
308
  so a path a pattern reaches twice is yielded once, as `pluck` does:
294
309
  `walk({'a': 1, 'b': 2}, '(a,*)')` yields `('a', 1)`, `('b', 2)`. Pass
295
- `duplicates=True` for the old behavior. See [Walk](#walk).
310
+ `duplicates=True` for the old behavior. See [Ipluck](#ipluck).
296
311
 
297
312
  ### v0.53.0
298
313
  - **`!` negates the whole path.** `!(metadata.*)` yields everything
@@ -496,6 +511,89 @@ so the caller never has to ask which kind of path it holds.
496
511
  >>> list(dotted.iget({'a': 1}, 'b', default=0))
497
512
  [0]
498
513
 
514
+ <a id="streaming-reads"></a>
515
+ ### Streaming reads
516
+
517
+ `iget`, `ipluck` and `iexpand`, and their `_multi` forms, are **streaming
518
+ reads**. Where `get` looks items up (`__getitem__`), a streaming read's
519
+ pattern iterates what it reads and yields one match at a time. So it reads
520
+ through a one-shot iterator too (a generator, a `map`, a cursor), drawing
521
+ from it only as far as it is asked:
522
+
523
+ >>> rows = iter([{'x': 1, 'y': 'a'}, {'x': 2, 'y': 'b'}, {'x': 1, 'y': 'c'}])
524
+ >>> list(dotted.iget({'rows': rows}, 'rows[*&x=1].y'))
525
+ ['a', 'c']
526
+
527
+ `get`, `has`, `pluck`, `expand` and the writes never read an iterator: to
528
+ them it is a value like any other, and it is left untouched.
529
+
530
+ >>> rows = iter([{'y': 1}, {'y': 2}])
531
+ >>> dotted.get({'rows': rows}, 'rows[*].y')
532
+ ()
533
+ >>> list(rows)
534
+ [{'y': 1}, {'y': 2}]
535
+
536
+ A slice of an iterator is an `islice` of it, one value, as a slice of a list
537
+ is a list; `[*]` then reads it, no further than the slice's bound. A slice
538
+ filter of one is likewise a generator of the items that pass.
539
+
540
+ >>> list(dotted.iget({'rows': iter([1, 2, 3, 4])}, 'rows[:2][*]'))
541
+ [1, 2]
542
+ >>> list(dotted.iget({'rows': iter([{'x': 1}, {'x': 2}])}, 'rows[x=2][*].x'))
543
+ [2]
544
+
545
+ What an iterator cannot answer does not match: an index (`rows[0]`), or a
546
+ slice from its end (`rows[-2:]`, `rows[::-1]`). It is not drawn from.
547
+
548
+ >>> list(dotted.iget({'rows': iter([1, 2])}, 'rows[0]', default='none'))
549
+ ['none']
550
+
551
+ `ipluck` and `iexpand` number an iterator's items by position, the paths a
552
+ list of the same items would have, so `pack` rebuilds from the pairs:
553
+
554
+ >>> rows = iter([{'y': 1}, {'y': 2}])
555
+ >>> list(dotted.ipluck({'rows': rows}, 'rows[*].y'))
556
+ [('rows[0].y', 1), ('rows[1].y', 2)]
557
+
558
+ An iterator is read once. A path that reaches the same one twice finds it
559
+ empty the second time, so group below it, not across it:
560
+
561
+ >>> rows = lambda: iter([{'a': 1, 'b': 2}, {'a': 3, 'b': 4}])
562
+ >>> list(dotted.iget({'rows': rows()}, 'rows[*](.a, .b)'))
563
+ [1, 2, 3, 4]
564
+ >>> list(dotted.iget({'rows': rows()}, '(rows[*].a, rows[*].b)'))
565
+ [1, 3]
566
+
567
+ A recursive pattern enters an iterator as it enters a list, and reads it to
568
+ its end before it yields. The matches are the same; the read is not lazy
569
+ there.
570
+
571
+ >>> d = {'a': {'rows': iter([{'y': 1}, {'y': 2}])}}
572
+ >>> list(dotted.iget(d, '*(*#, [*]).y'))
573
+ [1, 2]
574
+
575
+ A set is not read: it has no order, so its items have no positions to be
576
+ their paths.
577
+
578
+ >>> list(dotted.iget({'s': {1, 2}}, 's[*]'))
579
+ []
580
+
581
+ A dict-like is read through its own `items()`, in one pass, when it has
582
+ one, else through each key it iterates; a sequence or iterator through its
583
+ `__iter__`; anything else by index, as `get` reads it. For a lazy mapping
584
+ of your own, a lazy `items()` is the interface to implement.
585
+
586
+ `iget_multi` reads several paths as one flat stream of values, and
587
+ `ipluck_multi` and `iexpand_multi` are `pluck_multi` and `expand_multi` as
588
+ streaming reads. The paths of one call read the same object, so an iterator
589
+ one path has read is empty for the next, as it is for the next call:
590
+
591
+ >>> d = {'name': 'orders', 'rows': iter([{'y': 1}, {'y': 2}])}
592
+ >>> list(dotted.iget_multi(d, ['name', 'rows[*].y']))
593
+ ['orders', 1, 2]
594
+ >>> list(dotted.ipluck_multi(d, ['name', 'rows[*].y']))
595
+ [('name', 'orders')]
596
+
499
597
  <a id="update"></a>
500
598
  ### Update
501
599
 
@@ -824,13 +922,14 @@ Expand a pattern into all matching paths in an object.
824
922
  >>> dotted.expand(d, '*.*[1:]')
825
923
  ('hello.there[1:]',)
826
924
 
827
- A path the pattern reaches more than once is given once; pass
828
- `duplicates=True` to keep each. `iexpand` is `expand` as a generator.
925
+ A path the pattern reaches more than once is given each time; pass
926
+ `unique=True` for each path once. `iexpand` is `expand` as a generator, and
927
+ a [streaming read](#streaming-reads).
829
928
 
830
929
  >>> dotted.expand(d, '(bye,*)')
831
- ('bye', 'hello')
832
- >>> dotted.expand(d, '(bye,*)', duplicates=True)
833
930
  ('bye', 'hello', 'bye')
931
+ >>> dotted.expand(d, '(bye,*)', unique=True)
932
+ ('bye', 'hello')
834
933
  >>> list(dotted.iexpand(d, '*'))
835
934
  ['hello', 'bye']
836
935
 
@@ -918,20 +1017,20 @@ Extract (path, value) pairs from an object matching a pattern.
918
1017
  >>> dotted.pluck(d, 'nested.*')
919
1018
  (('nested.x', 10),)
920
1019
 
921
- A path the pattern reaches more than once is given once; pass
922
- `duplicates=True` to keep each.
1020
+ A path the pattern reaches more than once is given each time; pass
1021
+ `unique=True` for each path once.
923
1022
 
924
1023
  >>> dotted.pluck(d, '(a,*)')
925
- (('a', 1), ('b', 2), ('nested', {'x': 10}))
926
- >>> dotted.pluck(d, '(a,*)', duplicates=True)
927
1024
  (('a', 1), ('a', 1), ('b', 2), ('nested', {'x': 10}))
1025
+ >>> dotted.pluck(d, '(a,*)', unique=True)
1026
+ (('a', 1), ('b', 2), ('nested', {'x': 10}))
928
1027
 
929
- <a id="walk"></a>
930
- ### Walk
1028
+ <a id="ipluck"></a>
1029
+ ### Ipluck
931
1030
 
932
1031
  `ipluck` is `pluck` as a generator — it yields `(path, value)` pairs without
933
1032
  materializing the full result, for a concrete path as for a pattern. Useful
934
- for streaming or large structures. `walk` is another name for it.
1033
+ for streaming or large structures: it is a [streaming read](#streaming-reads).
935
1034
 
936
1035
  >>> import dotted
937
1036
  >>> d = {'a': {'b': 1, 'c': 2}, 'x': 3}
@@ -939,7 +1038,7 @@ for streaming or large structures. `walk` is another name for it.
939
1038
  [('a.b', 1), ('a.c', 2)]
940
1039
  >>> list(dotted.ipluck(d, 'a.b'))
941
1040
  [('a.b', 1)]
942
- >>> for path, val in dotted.walk(d, '*'):
1041
+ >>> for path, val in dotted.ipluck(d, '*'):
943
1042
  ... print(f'{path} = {val}')
944
1043
  a = {'b': 1, 'c': 2}
945
1044
  x = 3
@@ -958,6 +1057,13 @@ reconstruct the original object.
958
1057
  >>> dotted.pack(dotted.unpack(d)) == d
959
1058
  True
960
1059
 
1060
+ A one-shot iterator is a leaf: `unpack` does not read it, and it is in the
1061
+ normal form as itself. See [Streaming reads](#streaming-reads).
1062
+
1063
+ >>> rows = iter([{'y': 1}])
1064
+ >>> dotted.unpack({'name': 'orders', 'rows': rows}) == {'name': 'orders', 'rows': rows}
1065
+ True
1066
+
961
1067
  Pass `attrs=` to also descend into object attributes. The `Attrs` enum controls
962
1068
  which attributes are included:
963
1069
 
@@ -1139,8 +1245,9 @@ produce `[]`.
1139
1245
 
1140
1246
  Most operations have `*_multi` variants for batch processing:
1141
1247
 
1142
- **Note:** The read-side `_multi` APIs — `get_multi`, `match_multi`, `expand_multi`,
1143
- `pluck_multi`, `walk_multi`, `translate_multi`, `assemble_multi`, and
1248
+ **Note:** The read-side `_multi` APIs — `get_multi`, `iget_multi`, `match_multi`,
1249
+ `expand_multi`, `iexpand_multi`, `pluck_multi`, `ipluck_multi`,
1250
+ `translate_multi`, `assemble_multi`, and
1144
1251
  `setdefault_multi` — return a **generator**, not a list or tuple. Consume with
1145
1252
  `list()` / `tuple()` / `for`. The write-side `_multi` APIs (`update_multi`,
1146
1253
  `remove_multi`, `build_multi`, `apply_multi`, etc.) return the mutated object.
@@ -1167,7 +1274,8 @@ before a full traversal completes.
1167
1274
 
1168
1275
  Available multi operations: `get_multi`, `update_multi`, `update_if_multi`, `remove_multi`,
1169
1276
  `remove_if_multi`, `setdefault_multi`, `match_multi`, `expand_multi`, `apply_multi`,
1170
- `build_multi`, `pluck_multi`, `walk_multi`, `assemble_multi`.
1277
+ `build_multi`, `pluck_multi`, `assemble_multi`, and the streaming `iget_multi`,
1278
+ `iexpand_multi`, `ipluck_multi`.
1171
1279
 
1172
1280
  <a id="strict-mode"></a>
1173
1281
  ### Strict Mode
@@ -1667,7 +1775,7 @@ See [Replace](#replace) and [Translate](#translate) for full API details.
1667
1775
  <a id="template-bindings"></a>
1668
1776
  ### Template bindings
1669
1777
 
1670
- All traversal APIs — `get`, `update`, `remove`, `has`, `walk`, `expand`, `pluck`,
1778
+ All traversal APIs — `get`, `update`, `remove`, `has`, `ipluck`, `expand`, `pluck`,
1671
1779
  `apply`, `build`, `mutable`, `setdefault`, and their multi variants — accept a
1672
1780
  `bindings=` keyword argument to resolve template paths inline:
1673
1781
 
@@ -2032,7 +2140,11 @@ Here `*:dict` keeps the values that are dicts, and `.*` continues into them.
2032
2140
  The list and string are dropped.
2033
2141
 
2034
2142
  Supported types: `str`, `bytes`, `int`, `float`, `dict`, `list`, `tuple`,
2035
- `set`, `frozenset`, `bool`.
2143
+ `set`, `frozenset`, `bool`, and `iter`, a one-shot iterator (a generator, a
2144
+ `map`, a cursor):
2145
+
2146
+ >>> dotted.get({'rows': iter([1, 2]), 'tags': ['a']}, '*:!iter')
2147
+ (['a'],)
2036
2148
 
2037
2149
  <a id="positive-restrictions"></a>
2038
2150
  ### Positive restrictions
@@ -2504,7 +2616,7 @@ aggregate over the item:
2504
2616
  >>> dotted.get(d, 'items[*&(p[*];)|len=0]')
2505
2617
  ({'p': []},)
2506
2618
 
2507
- A pack is its own path segment: `walk` and `expand` give it back as
2619
+ A pack is its own path segment: `ipluck` and `expand` give it back as
2508
2620
  written, `(a.*;)|sum`. There is nothing under a tuple of matches to write
2509
2621
  to, so `update` and `remove` through a pack raise `ValueError`, and a pack
2510
2622
  cannot be negated. `;` is a reserved character; quote a key that contains
@@ -4360,6 +4472,19 @@ A `Column` binding is compared by its type, which `build` reads in the
4360
4472
  active session: `r.build(r.where, schema=df.schema,
4361
4473
  min_age=F.col('floor'))`.
4362
4474
 
4475
+ A substitution at a path's head starts the read at what `build` binds
4476
+ it to: a `Column`, or a column's name. A higher-order function's lambda
4477
+ argument is a Column no session can type, so `r.typed(column, dtype)`
4478
+ carries its type:
4479
+
4480
+ r = dotted.sparkize('$(item).id')
4481
+ elem = df.schema['xs'].dataType.elementType
4482
+ df.select(F.transform('xs', lambda e: r.build(
4483
+ r.select, schema=df.schema, item=r.typed(e, elem))))
4484
+
4485
+ `r.typed` is `dotted.translators.spark.typed`, and works for any Column
4486
+ binding. A write (`as_update`) can't start at a Column.
4487
+
4363
4488
  ### Composing fragments
4364
4489
 
4365
4490
  A `Column` can't hold a placeholder, so `r.where` is a
@@ -4468,7 +4593,7 @@ Not yet supported (`TranslationError`):
4468
4593
  `dotted.translators.flavors()` lists them.
4469
4594
  - `bindings` — resolve substitutions at sparkize time. Path-position
4470
4595
  substitutions must be resolved here, row indexes and slice bounds
4471
- included.
4596
+ included, but for one at a read's head, which `build` may bind.
4472
4597
  - `root` — `'column'` (default): the first segment is a column.
4473
4598
  `'table'`: a [table search](#sparkize-table-search).
4474
4599
 
@@ -51,6 +51,7 @@ For faster `mutable=False` updates and removes, install the
51
51
  - [Breaking Changes](#breaking-changes)
52
52
  - [API](#api)
53
53
  - [Get](#get)
54
+ - [Streaming reads](#streaming-reads)
54
55
  - [Update](#update)
55
56
  - [Remove](#remove)
56
57
  - [Match](#match)
@@ -62,7 +63,7 @@ For faster `mutable=False` updates and removes, install the
62
63
  - [Mutable](#mutable)
63
64
  - [Setdefault](#setdefault)
64
65
  - [Pluck](#pluck)
65
- - [Walk](#walk)
66
+ - [Ipluck](#ipluck)
66
67
  - [Unpack](#unpack)
67
68
  - [Pack](#pack)
68
69
  - [Keys, Values, Items](#keys-values-items)
@@ -225,10 +226,24 @@ Several Python libraries handle nested data access. Here's how dotted compares:
225
226
  - **String/bytes glob patterns**—match by prefix, suffix, or substring: `*="user_"...`, `*=b"header"...b"footer"`
226
227
  - **Value groups**—disjunction over filter values: `*=(1, 2, 3)`, `[*&status=("active", "pending")]`
227
228
  - **Strict mode**—enforce type separation: `[0]` only matches lists, `.key` only matches dicts
229
+ - **Streaming reads**—`iget`, `ipluck` and `iexpand` read through generators and other one-shot iterators, one match at a time: `rows[*&active=True].id` over a cursor
228
230
 
229
231
  <a id="breaking-changes"></a>
230
232
  ## Breaking Changes
231
233
 
234
+ ### v0.57.0
235
+ - **`pluck` and `expand` no longer dedup by default.** `unique=False`
236
+ replaces `duplicates=False` on `pluck`, `expand` and their `i` and `_multi`
237
+ forms: a path a pattern reaches twice is yielded twice.
238
+ Pass `unique=True` for each path once; `duplicates=` is gone and raises
239
+ `TypeError`. See [Pluck](#pluck).
240
+ - **`iget`, `ipluck` and `iexpand` are streaming reads.** A pattern
241
+ iterates what it reads, so they read through a one-shot iterator, which
242
+ yielded nothing before. See [Streaming reads](#streaming-reads).
243
+ - **`walk` and `walk_multi` are removed.** They were other names for
244
+ `ipluck` and `pluck_multi`; call `ipluck` and `ipluck_multi`. See
245
+ [Ipluck](#ipluck).
246
+
232
247
  ### v0.56.0
233
248
  - **`sparkize`'s `build` takes the DataFrame's schema.** A path reads
234
249
  each node by its type, so `r.build(fragment, schema=df.schema)`;
@@ -242,7 +257,7 @@ Several Python libraries handle nested data access. Here's how dotted compares:
242
257
  - **`walk` dedups.** It is now `ipluck`, and `walk_multi` is `pluck_multi`,
243
258
  so a path a pattern reaches twice is yielded once, as `pluck` does:
244
259
  `walk({'a': 1, 'b': 2}, '(a,*)')` yields `('a', 1)`, `('b', 2)`. Pass
245
- `duplicates=True` for the old behavior. See [Walk](#walk).
260
+ `duplicates=True` for the old behavior. See [Ipluck](#ipluck).
246
261
 
247
262
  ### v0.53.0
248
263
  - **`!` negates the whole path.** `!(metadata.*)` yields everything
@@ -446,6 +461,89 @@ so the caller never has to ask which kind of path it holds.
446
461
  >>> list(dotted.iget({'a': 1}, 'b', default=0))
447
462
  [0]
448
463
 
464
+ <a id="streaming-reads"></a>
465
+ ### Streaming reads
466
+
467
+ `iget`, `ipluck` and `iexpand`, and their `_multi` forms, are **streaming
468
+ reads**. Where `get` looks items up (`__getitem__`), a streaming read's
469
+ pattern iterates what it reads and yields one match at a time. So it reads
470
+ through a one-shot iterator too (a generator, a `map`, a cursor), drawing
471
+ from it only as far as it is asked:
472
+
473
+ >>> rows = iter([{'x': 1, 'y': 'a'}, {'x': 2, 'y': 'b'}, {'x': 1, 'y': 'c'}])
474
+ >>> list(dotted.iget({'rows': rows}, 'rows[*&x=1].y'))
475
+ ['a', 'c']
476
+
477
+ `get`, `has`, `pluck`, `expand` and the writes never read an iterator: to
478
+ them it is a value like any other, and it is left untouched.
479
+
480
+ >>> rows = iter([{'y': 1}, {'y': 2}])
481
+ >>> dotted.get({'rows': rows}, 'rows[*].y')
482
+ ()
483
+ >>> list(rows)
484
+ [{'y': 1}, {'y': 2}]
485
+
486
+ A slice of an iterator is an `islice` of it, one value, as a slice of a list
487
+ is a list; `[*]` then reads it, no further than the slice's bound. A slice
488
+ filter of one is likewise a generator of the items that pass.
489
+
490
+ >>> list(dotted.iget({'rows': iter([1, 2, 3, 4])}, 'rows[:2][*]'))
491
+ [1, 2]
492
+ >>> list(dotted.iget({'rows': iter([{'x': 1}, {'x': 2}])}, 'rows[x=2][*].x'))
493
+ [2]
494
+
495
+ What an iterator cannot answer does not match: an index (`rows[0]`), or a
496
+ slice from its end (`rows[-2:]`, `rows[::-1]`). It is not drawn from.
497
+
498
+ >>> list(dotted.iget({'rows': iter([1, 2])}, 'rows[0]', default='none'))
499
+ ['none']
500
+
501
+ `ipluck` and `iexpand` number an iterator's items by position, the paths a
502
+ list of the same items would have, so `pack` rebuilds from the pairs:
503
+
504
+ >>> rows = iter([{'y': 1}, {'y': 2}])
505
+ >>> list(dotted.ipluck({'rows': rows}, 'rows[*].y'))
506
+ [('rows[0].y', 1), ('rows[1].y', 2)]
507
+
508
+ An iterator is read once. A path that reaches the same one twice finds it
509
+ empty the second time, so group below it, not across it:
510
+
511
+ >>> rows = lambda: iter([{'a': 1, 'b': 2}, {'a': 3, 'b': 4}])
512
+ >>> list(dotted.iget({'rows': rows()}, 'rows[*](.a, .b)'))
513
+ [1, 2, 3, 4]
514
+ >>> list(dotted.iget({'rows': rows()}, '(rows[*].a, rows[*].b)'))
515
+ [1, 3]
516
+
517
+ A recursive pattern enters an iterator as it enters a list, and reads it to
518
+ its end before it yields. The matches are the same; the read is not lazy
519
+ there.
520
+
521
+ >>> d = {'a': {'rows': iter([{'y': 1}, {'y': 2}])}}
522
+ >>> list(dotted.iget(d, '*(*#, [*]).y'))
523
+ [1, 2]
524
+
525
+ A set is not read: it has no order, so its items have no positions to be
526
+ their paths.
527
+
528
+ >>> list(dotted.iget({'s': {1, 2}}, 's[*]'))
529
+ []
530
+
531
+ A dict-like is read through its own `items()`, in one pass, when it has
532
+ one, else through each key it iterates; a sequence or iterator through its
533
+ `__iter__`; anything else by index, as `get` reads it. For a lazy mapping
534
+ of your own, a lazy `items()` is the interface to implement.
535
+
536
+ `iget_multi` reads several paths as one flat stream of values, and
537
+ `ipluck_multi` and `iexpand_multi` are `pluck_multi` and `expand_multi` as
538
+ streaming reads. The paths of one call read the same object, so an iterator
539
+ one path has read is empty for the next, as it is for the next call:
540
+
541
+ >>> d = {'name': 'orders', 'rows': iter([{'y': 1}, {'y': 2}])}
542
+ >>> list(dotted.iget_multi(d, ['name', 'rows[*].y']))
543
+ ['orders', 1, 2]
544
+ >>> list(dotted.ipluck_multi(d, ['name', 'rows[*].y']))
545
+ [('name', 'orders')]
546
+
449
547
  <a id="update"></a>
450
548
  ### Update
451
549
 
@@ -774,13 +872,14 @@ Expand a pattern into all matching paths in an object.
774
872
  >>> dotted.expand(d, '*.*[1:]')
775
873
  ('hello.there[1:]',)
776
874
 
777
- A path the pattern reaches more than once is given once; pass
778
- `duplicates=True` to keep each. `iexpand` is `expand` as a generator.
875
+ A path the pattern reaches more than once is given each time; pass
876
+ `unique=True` for each path once. `iexpand` is `expand` as a generator, and
877
+ a [streaming read](#streaming-reads).
779
878
 
780
879
  >>> dotted.expand(d, '(bye,*)')
781
- ('bye', 'hello')
782
- >>> dotted.expand(d, '(bye,*)', duplicates=True)
783
880
  ('bye', 'hello', 'bye')
881
+ >>> dotted.expand(d, '(bye,*)', unique=True)
882
+ ('bye', 'hello')
784
883
  >>> list(dotted.iexpand(d, '*'))
785
884
  ['hello', 'bye']
786
885
 
@@ -868,20 +967,20 @@ Extract (path, value) pairs from an object matching a pattern.
868
967
  >>> dotted.pluck(d, 'nested.*')
869
968
  (('nested.x', 10),)
870
969
 
871
- A path the pattern reaches more than once is given once; pass
872
- `duplicates=True` to keep each.
970
+ A path the pattern reaches more than once is given each time; pass
971
+ `unique=True` for each path once.
873
972
 
874
973
  >>> dotted.pluck(d, '(a,*)')
875
- (('a', 1), ('b', 2), ('nested', {'x': 10}))
876
- >>> dotted.pluck(d, '(a,*)', duplicates=True)
877
974
  (('a', 1), ('a', 1), ('b', 2), ('nested', {'x': 10}))
975
+ >>> dotted.pluck(d, '(a,*)', unique=True)
976
+ (('a', 1), ('b', 2), ('nested', {'x': 10}))
878
977
 
879
- <a id="walk"></a>
880
- ### Walk
978
+ <a id="ipluck"></a>
979
+ ### Ipluck
881
980
 
882
981
  `ipluck` is `pluck` as a generator — it yields `(path, value)` pairs without
883
982
  materializing the full result, for a concrete path as for a pattern. Useful
884
- for streaming or large structures. `walk` is another name for it.
983
+ for streaming or large structures: it is a [streaming read](#streaming-reads).
885
984
 
886
985
  >>> import dotted
887
986
  >>> d = {'a': {'b': 1, 'c': 2}, 'x': 3}
@@ -889,7 +988,7 @@ for streaming or large structures. `walk` is another name for it.
889
988
  [('a.b', 1), ('a.c', 2)]
890
989
  >>> list(dotted.ipluck(d, 'a.b'))
891
990
  [('a.b', 1)]
892
- >>> for path, val in dotted.walk(d, '*'):
991
+ >>> for path, val in dotted.ipluck(d, '*'):
893
992
  ... print(f'{path} = {val}')
894
993
  a = {'b': 1, 'c': 2}
895
994
  x = 3
@@ -908,6 +1007,13 @@ reconstruct the original object.
908
1007
  >>> dotted.pack(dotted.unpack(d)) == d
909
1008
  True
910
1009
 
1010
+ A one-shot iterator is a leaf: `unpack` does not read it, and it is in the
1011
+ normal form as itself. See [Streaming reads](#streaming-reads).
1012
+
1013
+ >>> rows = iter([{'y': 1}])
1014
+ >>> dotted.unpack({'name': 'orders', 'rows': rows}) == {'name': 'orders', 'rows': rows}
1015
+ True
1016
+
911
1017
  Pass `attrs=` to also descend into object attributes. The `Attrs` enum controls
912
1018
  which attributes are included:
913
1019
 
@@ -1089,8 +1195,9 @@ produce `[]`.
1089
1195
 
1090
1196
  Most operations have `*_multi` variants for batch processing:
1091
1197
 
1092
- **Note:** The read-side `_multi` APIs — `get_multi`, `match_multi`, `expand_multi`,
1093
- `pluck_multi`, `walk_multi`, `translate_multi`, `assemble_multi`, and
1198
+ **Note:** The read-side `_multi` APIs — `get_multi`, `iget_multi`, `match_multi`,
1199
+ `expand_multi`, `iexpand_multi`, `pluck_multi`, `ipluck_multi`,
1200
+ `translate_multi`, `assemble_multi`, and
1094
1201
  `setdefault_multi` — return a **generator**, not a list or tuple. Consume with
1095
1202
  `list()` / `tuple()` / `for`. The write-side `_multi` APIs (`update_multi`,
1096
1203
  `remove_multi`, `build_multi`, `apply_multi`, etc.) return the mutated object.
@@ -1117,7 +1224,8 @@ before a full traversal completes.
1117
1224
 
1118
1225
  Available multi operations: `get_multi`, `update_multi`, `update_if_multi`, `remove_multi`,
1119
1226
  `remove_if_multi`, `setdefault_multi`, `match_multi`, `expand_multi`, `apply_multi`,
1120
- `build_multi`, `pluck_multi`, `walk_multi`, `assemble_multi`.
1227
+ `build_multi`, `pluck_multi`, `assemble_multi`, and the streaming `iget_multi`,
1228
+ `iexpand_multi`, `ipluck_multi`.
1121
1229
 
1122
1230
  <a id="strict-mode"></a>
1123
1231
  ### Strict Mode
@@ -1617,7 +1725,7 @@ See [Replace](#replace) and [Translate](#translate) for full API details.
1617
1725
  <a id="template-bindings"></a>
1618
1726
  ### Template bindings
1619
1727
 
1620
- All traversal APIs — `get`, `update`, `remove`, `has`, `walk`, `expand`, `pluck`,
1728
+ All traversal APIs — `get`, `update`, `remove`, `has`, `ipluck`, `expand`, `pluck`,
1621
1729
  `apply`, `build`, `mutable`, `setdefault`, and their multi variants — accept a
1622
1730
  `bindings=` keyword argument to resolve template paths inline:
1623
1731
 
@@ -1982,7 +2090,11 @@ Here `*:dict` keeps the values that are dicts, and `.*` continues into them.
1982
2090
  The list and string are dropped.
1983
2091
 
1984
2092
  Supported types: `str`, `bytes`, `int`, `float`, `dict`, `list`, `tuple`,
1985
- `set`, `frozenset`, `bool`.
2093
+ `set`, `frozenset`, `bool`, and `iter`, a one-shot iterator (a generator, a
2094
+ `map`, a cursor):
2095
+
2096
+ >>> dotted.get({'rows': iter([1, 2]), 'tags': ['a']}, '*:!iter')
2097
+ (['a'],)
1986
2098
 
1987
2099
  <a id="positive-restrictions"></a>
1988
2100
  ### Positive restrictions
@@ -2454,7 +2566,7 @@ aggregate over the item:
2454
2566
  >>> dotted.get(d, 'items[*&(p[*];)|len=0]')
2455
2567
  ({'p': []},)
2456
2568
 
2457
- A pack is its own path segment: `walk` and `expand` give it back as
2569
+ A pack is its own path segment: `ipluck` and `expand` give it back as
2458
2570
  written, `(a.*;)|sum`. There is nothing under a tuple of matches to write
2459
2571
  to, so `update` and `remove` through a pack raise `ValueError`, and a pack
2460
2572
  cannot be negated. `;` is a reserved character; quote a key that contains
@@ -4310,6 +4422,19 @@ A `Column` binding is compared by its type, which `build` reads in the
4310
4422
  active session: `r.build(r.where, schema=df.schema,
4311
4423
  min_age=F.col('floor'))`.
4312
4424
 
4425
+ A substitution at a path's head starts the read at what `build` binds
4426
+ it to: a `Column`, or a column's name. A higher-order function's lambda
4427
+ argument is a Column no session can type, so `r.typed(column, dtype)`
4428
+ carries its type:
4429
+
4430
+ r = dotted.sparkize('$(item).id')
4431
+ elem = df.schema['xs'].dataType.elementType
4432
+ df.select(F.transform('xs', lambda e: r.build(
4433
+ r.select, schema=df.schema, item=r.typed(e, elem))))
4434
+
4435
+ `r.typed` is `dotted.translators.spark.typed`, and works for any Column
4436
+ binding. A write (`as_update`) can't start at a Column.
4437
+
4313
4438
  ### Composing fragments
4314
4439
 
4315
4440
  A `Column` can't hold a placeholder, so `r.where` is a
@@ -4418,7 +4543,7 @@ Not yet supported (`TranslationError`):
4418
4543
  `dotted.translators.flavors()` lists them.
4419
4544
  - `bindings` — resolve substitutions at sparkize time. Path-position
4420
4545
  substitutions must be resolved here, row indexes and slice bounds
4421
- included.
4546
+ included, but for one at a read's head, which `build` may bind.
4422
4547
  - `root` — `'column'` (default): the first segment is a column.
4423
4548
  `'table'`: a [table search](#sparkize-table-search).
4424
4549