pickle-debug 2.0__tar.gz → 2.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pickle_debug
3
- Version: 2.0
3
+ Version: 2.1
4
4
  Summary: Store expensive objects from debugging
5
5
  Author: Gerard
6
6
  Author-email: gweatherby@uchc.edu
@@ -90,9 +90,10 @@ plain functions.
90
90
 
91
91
  ## API
92
92
 
93
- ### `enable(directory)`
93
+ ### `enable(directory: str | Path | None)`
94
94
  Turn caching on, storing results in `directory` (a `str` or `Path`). The directory is created if
95
95
  needed and checked for writability. Raises `OSError` if it cannot be created or written.
96
+ enable(None) disables caching.
96
97
 
97
98
  ### `cached(func)`
98
99
  Decorator. Returns a wrapper (using `functools.wraps`) that:
@@ -78,9 +78,10 @@ plain functions.
78
78
 
79
79
  ## API
80
80
 
81
- ### `enable(directory)`
81
+ ### `enable(directory: str | Path | None)`
82
82
  Turn caching on, storing results in `directory` (a `str` or `Path`). The directory is created if
83
83
  needed and checked for writability. Raises `OSError` if it cannot be created or written.
84
+ enable(None) disables caching.
84
85
 
85
86
  ### `cached(func)`
86
87
  Decorator. Returns a wrapper (using `functools.wraps`) that:
@@ -2,7 +2,7 @@
2
2
  name = "pickle_debug"
3
3
  description = "Store expensive objects from debugging"
4
4
  license = {text = "MIT" }
5
- version = "2.0"
5
+ version = "2.1"
6
6
  dependencies = []
7
7
  requires-python= ">= 3.12"
8
8
  readme = "README.md"
@@ -18,16 +18,19 @@ _CACHE_DIRECTORY: Path | None = None
18
18
  _SUFFIX = '.pickle'
19
19
 
20
20
 
21
- def enable(directory: Path | str) -> None:
21
+ def enable(directory: Path | str|None) -> None:
22
22
  """Enable caching in specified directory. Raises OSError if directory can't be created or written"""
23
23
  global _CACHE_DIRECTORY
24
- directory = Path(directory)
25
- directory.mkdir(parents=True, exist_ok=True)
26
- # verify we can create and write files
27
- with tempfile.TemporaryFile(dir=directory) as f:
28
- f.write(b'test')
29
- _CACHE_DIRECTORY = directory
30
- pickle_debug_logger.debug(f"caching to {directory}")
24
+ if directory is not None:
25
+ directory = Path(directory)
26
+ directory.mkdir(parents=True, exist_ok=True)
27
+ # verify we can create and write files
28
+ with tempfile.TemporaryFile(dir=directory) as f:
29
+ f.write(b'test')
30
+ _CACHE_DIRECTORY = directory
31
+ pickle_debug_logger.debug(f"caching to {directory}")
32
+ else:
33
+ _CACHE_DIRECTORY = None
31
34
 
32
35
 
33
36
  def reset() -> None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pickle_debug
3
- Version: 2.0
3
+ Version: 2.1
4
4
  Summary: Store expensive objects from debugging
5
5
  Author: Gerard
6
6
  Author-email: gweatherby@uchc.edu
@@ -90,9 +90,10 @@ plain functions.
90
90
 
91
91
  ## API
92
92
 
93
- ### `enable(directory)`
93
+ ### `enable(directory: str | Path | None)`
94
94
  Turn caching on, storing results in `directory` (a `str` or `Path`). The directory is created if
95
95
  needed and checked for writability. Raises `OSError` if it cannot be created or written.
96
+ enable(None) disables caching.
96
97
 
97
98
  ### `cached(func)`
98
99
  Decorator. Returns a wrapper (using `functools.wraps`) that:
@@ -6,6 +6,7 @@ src/pickle_debug.egg-info/PKG-INFO
6
6
  src/pickle_debug.egg-info/SOURCES.txt
7
7
  src/pickle_debug.egg-info/dependency_links.txt
8
8
  src/pickle_debug.egg-info/top_level.txt
9
+ src/test/ntest.py
9
10
  src/test/patch_test.py
10
11
  src/test/pd_test.py
11
12
  src/test/ttest.py
@@ -0,0 +1,15 @@
1
+ import time
2
+
3
+ import pickle_debug
4
+
5
+
6
+ @pickle_debug.cached
7
+ def f(x, y=1):
8
+ print(f"call {x} {y}")
9
+ time.sleep(1.5)
10
+ return x + y
11
+
12
+
13
+ pickle_debug.enable(None)
14
+ print(f(1, 2))
15
+ print(f(1, 2))
File without changes
File without changes
File without changes