dotted-notation 0.44.8__tar.gz → 0.44.10__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 (39) hide show
  1. {dotted_notation-0.44.8 → dotted_notation-0.44.10}/CHANGELOG.md +51 -0
  2. {dotted_notation-0.44.8/dotted_notation.egg-info → dotted_notation-0.44.10}/PKG-INFO +24 -2
  3. {dotted_notation-0.44.8 → dotted_notation-0.44.10}/README.md +17 -1
  4. {dotted_notation-0.44.8 → dotted_notation-0.44.10}/dotted/api.py +25 -7
  5. {dotted_notation-0.44.8 → dotted_notation-0.44.10}/dotted/engine.py +2 -2
  6. {dotted_notation-0.44.8 → dotted_notation-0.44.10}/dotted/utils.py +6 -0
  7. {dotted_notation-0.44.8 → dotted_notation-0.44.10/dotted_notation.egg-info}/PKG-INFO +24 -2
  8. dotted_notation-0.44.10/dotted_notation.egg-info/requires.txt +29 -0
  9. {dotted_notation-0.44.8 → dotted_notation-0.44.10}/pyproject.toml +8 -1
  10. dotted_notation-0.44.8/dotted_notation.egg-info/requires.txt +0 -17
  11. {dotted_notation-0.44.8 → dotted_notation-0.44.10}/LICENSE +0 -0
  12. {dotted_notation-0.44.8 → dotted_notation-0.44.10}/MANIFEST.in +0 -0
  13. {dotted_notation-0.44.8 → dotted_notation-0.44.10}/dotted/__init__.py +0 -0
  14. {dotted_notation-0.44.8 → dotted_notation-0.44.10}/dotted/__main__.py +0 -0
  15. {dotted_notation-0.44.8 → dotted_notation-0.44.10}/dotted/access.py +0 -0
  16. {dotted_notation-0.44.8 → dotted_notation-0.44.10}/dotted/base.py +0 -0
  17. {dotted_notation-0.44.8 → dotted_notation-0.44.10}/dotted/cli/__init__.py +0 -0
  18. {dotted_notation-0.44.8 → dotted_notation-0.44.10}/dotted/cli/_compat.py +0 -0
  19. {dotted_notation-0.44.8 → dotted_notation-0.44.10}/dotted/cli/formats.py +0 -0
  20. {dotted_notation-0.44.8 → dotted_notation-0.44.10}/dotted/cli/main.py +0 -0
  21. {dotted_notation-0.44.8 → dotted_notation-0.44.10}/dotted/containers.py +0 -0
  22. {dotted_notation-0.44.8 → dotted_notation-0.44.10}/dotted/filters.py +0 -0
  23. {dotted_notation-0.44.8 → dotted_notation-0.44.10}/dotted/grammar.py +0 -0
  24. {dotted_notation-0.44.8 → dotted_notation-0.44.10}/dotted/groups.py +0 -0
  25. {dotted_notation-0.44.8 → dotted_notation-0.44.10}/dotted/matchers.py +0 -0
  26. {dotted_notation-0.44.8 → dotted_notation-0.44.10}/dotted/predicates.py +0 -0
  27. {dotted_notation-0.44.8 → dotted_notation-0.44.10}/dotted/recursive.py +0 -0
  28. {dotted_notation-0.44.8 → dotted_notation-0.44.10}/dotted/results.py +0 -0
  29. {dotted_notation-0.44.8 → dotted_notation-0.44.10}/dotted/sql/__init__.py +0 -0
  30. {dotted_notation-0.44.8 → dotted_notation-0.44.10}/dotted/sql/core.py +0 -0
  31. {dotted_notation-0.44.8 → dotted_notation-0.44.10}/dotted/sql/pg.py +0 -0
  32. {dotted_notation-0.44.8 → dotted_notation-0.44.10}/dotted/transforms.py +0 -0
  33. {dotted_notation-0.44.8 → dotted_notation-0.44.10}/dotted/utypes.py +0 -0
  34. {dotted_notation-0.44.8 → dotted_notation-0.44.10}/dotted/wrappers.py +0 -0
  35. {dotted_notation-0.44.8 → dotted_notation-0.44.10}/dotted_notation.egg-info/SOURCES.txt +0 -0
  36. {dotted_notation-0.44.8 → dotted_notation-0.44.10}/dotted_notation.egg-info/dependency_links.txt +0 -0
  37. {dotted_notation-0.44.8 → dotted_notation-0.44.10}/dotted_notation.egg-info/entry_points.txt +0 -0
  38. {dotted_notation-0.44.8 → dotted_notation-0.44.10}/dotted_notation.egg-info/top_level.txt +0 -0
  39. {dotted_notation-0.44.8 → dotted_notation-0.44.10}/setup.cfg +0 -0
@@ -3,6 +3,57 @@
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.44.10]
7
+
8
+ ### Performance
9
+ - `build()` and `build_multi()` keep the parsed paths they expand
10
+ instead of assembling each one to a string and parsing it again. A
11
+ pattern matching more paths than the parse cache holds (300) used to
12
+ miss on every one; `build` over 1000 matches is about 35x faster.
13
+
14
+ ### Changed
15
+ - Three edge cases of `build()` change with the string round trip gone:
16
+ with `strict=True`, a trailing `[]` or `[:]` now creates the empty
17
+ list where it was a no-op, and raises `TypeError` on a list root; a
18
+ wildcard over keys that cannot be written as a path, such as `None` or
19
+ `True`, now succeeds where it raised `AttributeError`.
20
+
21
+ ### Added
22
+ - Benchmark suite: `python -m benchmarks` or `make bench`. Times reads
23
+ and writes at two data sizes, and the copying cases under both
24
+ `copy.deepcopy` and copium. Results can be saved and compared.
25
+
26
+ ### Fixed
27
+ - `make` targets failed because the install rule depended on
28
+ `setup.py`, removed in the move to `pyproject.toml`.
29
+
30
+ ### Documentation
31
+ - README caveat for the `copium` extra: copium 0.1.0 gets slower at
32
+ copying small objects once it has copied a large one in the same
33
+ process. Reported upstream as
34
+ [copium#54](https://github.com/percolab/copium/issues/54).
35
+
36
+ ## [0.44.9]
37
+
38
+ ### Performance
39
+ - Optional [copium](https://github.com/Bobronium/copium) support: a C
40
+ implementation of `copy.deepcopy` with the same semantics. When
41
+ installed, the copies made by `mutable=False` updates and removes and
42
+ by `build()` use it (roughly 5-20x faster on plain nested data);
43
+ otherwise dotted falls back to `copy.deepcopy`. Install with
44
+ `pip install dotted-notation[copium]` (CPython 3.10+).
45
+
46
+ ### Added
47
+ - `copium` extra, and a `formats` extra bundling YAML and TOML support.
48
+
49
+ ### Deprecated
50
+ - The `all` extra. It is an alias for `formats` and will be removed in
51
+ a future release.
52
+
53
+ ### Changed
54
+ - When copium is installed the test suite runs every test function
55
+ under both deepcopy implementations.
56
+
6
57
  ## [0.44.8]
7
58
 
8
59
  ### Added
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dotted_notation
3
- Version: 0.44.8
3
+ Version: 0.44.10
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: MIT
@@ -27,11 +27,17 @@ Requires-Python: >=3.6
27
27
  Description-Content-Type: text/markdown
28
28
  License-File: LICENSE
29
29
  Requires-Dist: pyparsing>=3.0
30
+ Provides-Extra: copium
31
+ Requires-Dist: copium>=0.1.0; (python_version >= "3.10" and platform_python_implementation == "CPython") and extra == "copium"
30
32
  Provides-Extra: yaml
31
33
  Requires-Dist: PyYAML>=5.0; extra == "yaml"
32
34
  Provides-Extra: toml
33
35
  Requires-Dist: tomli>=1.0; python_version < "3.11" and extra == "toml"
34
36
  Requires-Dist: tomli_w>=1.0; extra == "toml"
37
+ Provides-Extra: formats
38
+ Requires-Dist: PyYAML>=5.0; extra == "formats"
39
+ Requires-Dist: tomli>=1.0; python_version < "3.11" and extra == "formats"
40
+ Requires-Dist: tomli_w>=1.0; extra == "formats"
35
41
  Provides-Extra: all
36
42
  Requires-Dist: PyYAML>=5.0; extra == "all"
37
43
  Requires-Dist: tomli>=1.0; python_version < "3.11" and extra == "all"
@@ -61,12 +67,28 @@ Since this package includes the [**`dq`** command-line tool](#cli-dq), several d
61
67
 
62
68
  To install optional format support:
63
69
 
64
- pip install dotted-notation[all]
70
+ pip install dotted-notation[formats]
65
71
 
66
72
  Or pick only what you need:
67
73
 
68
74
  pip install dotted-notation[yaml,toml]
69
75
 
76
+ > **Deprecated:** the `all` extra is an alias for `formats` and will be removed
77
+ > in a future release. Use `formats` instead.
78
+
79
+ For faster `mutable=False` updates and removes, install the
80
+ [copium](https://github.com/Bobronium/copium) extra, a C implementation of
81
+ `copy.deepcopy` (CPython 3.10+). Dotted uses it when present and falls back to
82
+ `copy.deepcopy` otherwise:
83
+
84
+ pip install dotted-notation[copium]
85
+
86
+ > **Caveat (copium 0.1.0):** after copium copies a large object, its copies of
87
+ > small objects in the same process become slower than `copy.deepcopy` and stay
88
+ > that way. Copying whole documents is 3-9x faster, but a long-running process
89
+ > that mixes one large copy with many small ones can come out slower overall.
90
+ > Tracked upstream in [copium#54](https://github.com/percolab/copium/issues/54).
91
+
70
92
  ## Table of Contents
71
93
 
72
94
  - [Safe Traversal (Optional Chaining)](#safe-traversal-optional-chaining)
@@ -21,12 +21,28 @@ Since this package includes the [**`dq`** command-line tool](#cli-dq), several d
21
21
 
22
22
  To install optional format support:
23
23
 
24
- pip install dotted-notation[all]
24
+ pip install dotted-notation[formats]
25
25
 
26
26
  Or pick only what you need:
27
27
 
28
28
  pip install dotted-notation[yaml,toml]
29
29
 
30
+ > **Deprecated:** the `all` extra is an alias for `formats` and will be removed
31
+ > in a future release. Use `formats` instead.
32
+
33
+ For faster `mutable=False` updates and removes, install the
34
+ [copium](https://github.com/Bobronium/copium) extra, a C implementation of
35
+ `copy.deepcopy` (CPython 3.10+). Dotted uses it when present and falls back to
36
+ `copy.deepcopy` otherwise:
37
+
38
+ pip install dotted-notation[copium]
39
+
40
+ > **Caveat (copium 0.1.0):** after copium copies a large object, its copies of
41
+ > small objects in the same process become slower than `copy.deepcopy` and stay
42
+ > that way. Copying whole documents is 3-9x faster, but a long-running process
43
+ > that mixes one large copy with many small ones can come out slower overall.
44
+ > Tracked upstream in [copium#54](https://github.com/percolab/copium/issues/54).
45
+
30
46
  ## Table of Contents
31
47
 
32
48
  - [Safe Traversal (Optional Chaining)](#safe-traversal-optional-chaining)
@@ -1,7 +1,6 @@
1
1
  """
2
2
  Main api
3
3
  """
4
- import copy
5
4
  import enum
6
5
  import functools
7
6
  import itertools
@@ -14,6 +13,7 @@ from . import transforms
14
13
  from . import base
15
14
  from . import access
16
15
  from . import matchers
16
+ from . import utils
17
17
  from . import utypes
18
18
 
19
19
 
@@ -396,6 +396,23 @@ _mutable = mutable
396
396
  is_mutable = mutable
397
397
 
398
398
 
399
+ def _pluck_parsed(obj, ops, strict=False):
400
+ """
401
+ Yield deduped (parsed path, value) pairs from obj matching `ops`.
402
+ Like pluck_multi, but the paths stay parsed so callers that hand them
403
+ straight back to dotted skip the assemble and re-parse.
404
+ """
405
+ seen = set()
406
+ for path, val in engine.walk(ops, obj, paths=True, strict=strict):
407
+ if path is utypes.CUT_SENTINEL:
408
+ break
409
+ found = results.Dotted({'ops': path, 'transforms': ops.transforms})
410
+ if found in seen:
411
+ continue
412
+ seen.add(found)
413
+ yield (found, val)
414
+
415
+
399
416
  def build_multi(obj, paths, strict=False, bindings=None):
400
417
  """
401
418
  Build a subset/default obj based on concrete path fields
@@ -406,8 +423,9 @@ def build_multi(obj, paths, strict=False, bindings=None):
406
423
  if obj is AUTO:
407
424
  obj = _auto_root(((p, None) for p in paths))
408
425
  for path in paths:
409
- built = engine.build(parse(path, bindings=bindings, partial=False), obj, strict=strict)
410
- obj = update_multi(obj, pluck_multi(built, (path,), strict=strict), strict=strict)
426
+ ops = parse(path, bindings=bindings, partial=False)
427
+ built = engine.build(ops, obj, strict=strict)
428
+ obj = update_multi(obj, _pluck_parsed(built, ops, strict=strict), strict=strict)
411
429
  return obj
412
430
 
413
431
 
@@ -544,7 +562,7 @@ def update_if(obj, path, val, pred=lambda val: val is not None, mutable=True, ap
544
562
  if obj is AUTO:
545
563
  obj = _auto_root_from_path(path)
546
564
  if not mutable and _is_mutable_container(obj):
547
- obj = copy.deepcopy(obj)
565
+ obj = utils.deepcopy(obj)
548
566
  mutable = True
549
567
 
550
568
  if pred is not None and not pred(val):
@@ -562,7 +580,7 @@ def update_if_multi(obj, items, pred=lambda val: val is not None, mutable=True,
562
580
  {'a': 1, 'c': 3}
563
581
  """
564
582
  if not mutable and _is_mutable_container(obj):
565
- obj = copy.deepcopy(obj)
583
+ obj = utils.deepcopy(obj)
566
584
  mutable = True
567
585
  for item in items:
568
586
  path, val, *rest = item
@@ -646,7 +664,7 @@ def remove_if(obj, path, pred=lambda path: path is not None, val=ANY, mutable=Tr
646
664
  if obj is AUTO:
647
665
  obj = _auto_root_from_path(path)
648
666
  if not mutable and _is_mutable_container(obj):
649
- obj = copy.deepcopy(obj)
667
+ obj = utils.deepcopy(obj)
650
668
  mutable = True
651
669
 
652
670
  if pred is not None and not pred(path):
@@ -663,7 +681,7 @@ def remove_if_multi(obj, items, paths_only=True, pred=lambda path: path is not N
663
681
  {}
664
682
  """
665
683
  if not mutable and _is_mutable_container(obj):
666
- obj = copy.deepcopy(obj)
684
+ obj = utils.deepcopy(obj)
667
685
  mutable = True
668
686
 
669
687
  if paths_only:
@@ -3,10 +3,10 @@ Traversal engine for dotted path operations.
3
3
 
4
4
  Core traversal functions (walk, gets, updates, removes, expands).
5
5
  """
6
- import copy
7
6
 
8
7
  from . import base
9
8
  from . import matchers
9
+ from . import utils
10
10
  from . import wrappers
11
11
  from .access import Attr, Slot
12
12
  from .results import Dotted
@@ -42,7 +42,7 @@ def build(ops, node, deepcopy=True, **kwargs):
42
42
  built = node.__class__()
43
43
  for k,v in cur.items(node, **kwargs):
44
44
  if not ops:
45
- built = cur.update(built, k, copy.deepcopy(v) if deepcopy else v)
45
+ built = cur.update(built, k, utils.deepcopy(v) if deepcopy else v)
46
46
  else:
47
47
  built = cur.update(built, k, build(ops, v, deepcopy=deepcopy, **kwargs))
48
48
  return built or build_default([cur]+ops)
@@ -1,6 +1,12 @@
1
1
  """
2
2
  Shared type-checking helpers (duck-typing).
3
3
  """
4
+ try:
5
+ # C implementation of copy.deepcopy with identical semantics;
6
+ # installed by the [copium] extra.
7
+ from copium import deepcopy
8
+ except ImportError:
9
+ from copy import deepcopy
4
10
 
5
11
  class lazyprop:
6
12
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dotted_notation
3
- Version: 0.44.8
3
+ Version: 0.44.10
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: MIT
@@ -27,11 +27,17 @@ Requires-Python: >=3.6
27
27
  Description-Content-Type: text/markdown
28
28
  License-File: LICENSE
29
29
  Requires-Dist: pyparsing>=3.0
30
+ Provides-Extra: copium
31
+ Requires-Dist: copium>=0.1.0; (python_version >= "3.10" and platform_python_implementation == "CPython") and extra == "copium"
30
32
  Provides-Extra: yaml
31
33
  Requires-Dist: PyYAML>=5.0; extra == "yaml"
32
34
  Provides-Extra: toml
33
35
  Requires-Dist: tomli>=1.0; python_version < "3.11" and extra == "toml"
34
36
  Requires-Dist: tomli_w>=1.0; extra == "toml"
37
+ Provides-Extra: formats
38
+ Requires-Dist: PyYAML>=5.0; extra == "formats"
39
+ Requires-Dist: tomli>=1.0; python_version < "3.11" and extra == "formats"
40
+ Requires-Dist: tomli_w>=1.0; extra == "formats"
35
41
  Provides-Extra: all
36
42
  Requires-Dist: PyYAML>=5.0; extra == "all"
37
43
  Requires-Dist: tomli>=1.0; python_version < "3.11" and extra == "all"
@@ -61,12 +67,28 @@ Since this package includes the [**`dq`** command-line tool](#cli-dq), several d
61
67
 
62
68
  To install optional format support:
63
69
 
64
- pip install dotted-notation[all]
70
+ pip install dotted-notation[formats]
65
71
 
66
72
  Or pick only what you need:
67
73
 
68
74
  pip install dotted-notation[yaml,toml]
69
75
 
76
+ > **Deprecated:** the `all` extra is an alias for `formats` and will be removed
77
+ > in a future release. Use `formats` instead.
78
+
79
+ For faster `mutable=False` updates and removes, install the
80
+ [copium](https://github.com/Bobronium/copium) extra, a C implementation of
81
+ `copy.deepcopy` (CPython 3.10+). Dotted uses it when present and falls back to
82
+ `copy.deepcopy` otherwise:
83
+
84
+ pip install dotted-notation[copium]
85
+
86
+ > **Caveat (copium 0.1.0):** after copium copies a large object, its copies of
87
+ > small objects in the same process become slower than `copy.deepcopy` and stay
88
+ > that way. Copying whole documents is 3-9x faster, but a long-running process
89
+ > that mixes one large copy with many small ones can come out slower overall.
90
+ > Tracked upstream in [copium#54](https://github.com/percolab/copium/issues/54).
91
+
70
92
  ## Table of Contents
71
93
 
72
94
  - [Safe Traversal (Optional Chaining)](#safe-traversal-optional-chaining)
@@ -0,0 +1,29 @@
1
+ pyparsing>=3.0
2
+
3
+ [all]
4
+ PyYAML>=5.0
5
+ tomli_w>=1.0
6
+
7
+ [all:python_version < "3.11"]
8
+ tomli>=1.0
9
+
10
+ [copium]
11
+
12
+ [copium:python_version >= "3.10" and platform_python_implementation == "CPython"]
13
+ copium>=0.1.0
14
+
15
+ [formats]
16
+ PyYAML>=5.0
17
+ tomli_w>=1.0
18
+
19
+ [formats:python_version < "3.11"]
20
+ tomli>=1.0
21
+
22
+ [toml]
23
+ tomli_w>=1.0
24
+
25
+ [toml:python_version < "3.11"]
26
+ tomli>=1.0
27
+
28
+ [yaml]
29
+ PyYAML>=5.0
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "dotted_notation"
7
- version = "0.44.8"
7
+ version = "0.44.10"
8
8
  description = "Dotted notation for safe nested data traversal with optional chaining, pattern matching, and transforms"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.6"
@@ -44,8 +44,15 @@ dependencies = [
44
44
  ]
45
45
 
46
46
  [project.optional-dependencies]
47
+ copium = ['copium>=0.1.0;python_version>="3.10" and platform_python_implementation=="CPython"']
47
48
  yaml = ["PyYAML>=5.0"]
48
49
  toml = ['tomli>=1.0;python_version<"3.11"', "tomli_w>=1.0"]
50
+ formats = [
51
+ "PyYAML>=5.0",
52
+ 'tomli>=1.0;python_version<"3.11"',
53
+ "tomli_w>=1.0",
54
+ ]
55
+ # DEPRECATED: legacy alias for formats, to be removed in a future release
49
56
  all = [
50
57
  "PyYAML>=5.0",
51
58
  'tomli>=1.0;python_version<"3.11"',
@@ -1,17 +0,0 @@
1
- pyparsing>=3.0
2
-
3
- [all]
4
- PyYAML>=5.0
5
- tomli_w>=1.0
6
-
7
- [all:python_version < "3.11"]
8
- tomli>=1.0
9
-
10
- [toml]
11
- tomli_w>=1.0
12
-
13
- [toml:python_version < "3.11"]
14
- tomli>=1.0
15
-
16
- [yaml]
17
- PyYAML>=5.0