persidict 0.2.5__tar.gz → 0.3.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.

Potentially problematic release.


This version of persidict might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: persidict
3
- Version: 0.2.5
3
+ Version: 0.3.1
4
4
  Summary: Simple persistent key-value store for Python. Values are stored as files on a disk or as S3 objects on AWS cloud.
5
5
  Home-page: https://github.com/vladlpavlov/persidict
6
6
  Author: Vlad (Volodymyr) Pavlov
@@ -18,6 +18,14 @@ Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
18
  Requires-Python: >=3.8
19
19
  Description-Content-Type: text/markdown
20
20
  License-File: LICENSE
21
+ Requires-Dist: lz4
22
+ Requires-Dist: joblib
23
+ Requires-Dist: numpy
24
+ Requires-Dist: pandas
25
+ Requires-Dist: jsonpickle
26
+ Requires-Dist: boto3
27
+ Requires-Dist: moto
28
+ Requires-Dist: pytest
21
29
 
22
30
  # persidict
23
31
 
@@ -143,8 +151,8 @@ that simultaneously work with the same instance of a dictionary.
143
151
  * Values must be pickleable Python objects.
144
152
  * Insertion order is not preserved.
145
153
  * You can not assign initial key-value pairs to a dictionary in its constructor.
146
- * Methods `delete_if_exists()`, `mtimestamp()`, `get_subdict()` and `subdicts()`
147
- are available
154
+ * `PersiDict` API has methods = `delete_if_exists()`, `mtimestamp()`,
155
+ `get_subdict()` and `subdicts()` , which are not available in Python dicts.
148
156
 
149
157
  ## Fine Tuning
150
158
 
@@ -152,13 +160,13 @@ are available
152
160
  to impact behaviour of a dictionary.
153
161
 
154
162
  * `file_type` - a string that specifies the type of files used to store objects.
155
- Possible values are "json" and "pkl". Default value is "pkl".
163
+ Possible values are "json" and "lz4". Default value is "lz4".
156
164
  Storing objects as JSON files is mostly supported for debugging purposes.
157
165
  * `immutable_items` - a boolean that specifies whether items in a dictionary
158
166
  can be modified/deleted. It enables various distributed cache optimizations
159
167
  for remote storage. True means an append-only dictionary.
160
168
  False means normal dict-like behaviour. The default value is False.
161
- * `digest_len` - a length of a hash signature suffix which `persidict`
169
+ * `digest_len` - a length of a hash signature suffix which `PersiDict`
162
170
  automatically adds to each string in a key while mapping the key to
163
171
  the address of a value in a persistent storage backend
164
172
  (e.g. a filename or an S3 objectname). It is needed to ensure correct work
@@ -179,6 +187,7 @@ Binary installers for the latest released version are available at the Python pa
179
187
  ## Dependencies
180
188
 
181
189
  * [jsonpickle](https://jsonpickle.github.io)
190
+ * [joblib](https://joblib.readthedocs.io)
182
191
  * [pandas](https://pandas.pydata.org)
183
192
  * [numpy](https://numpy.org)
184
193
  * [boto3](https://boto3.readthedocs.io)
@@ -122,8 +122,8 @@ that simultaneously work with the same instance of a dictionary.
122
122
  * Values must be pickleable Python objects.
123
123
  * Insertion order is not preserved.
124
124
  * You can not assign initial key-value pairs to a dictionary in its constructor.
125
- * Methods `delete_if_exists()`, `mtimestamp()`, `get_subdict()` and `subdicts()`
126
- are available
125
+ * `PersiDict` API has methods = `delete_if_exists()`, `mtimestamp()`,
126
+ `get_subdict()` and `subdicts()` , which are not available in Python dicts.
127
127
 
128
128
  ## Fine Tuning
129
129
 
@@ -131,13 +131,13 @@ are available
131
131
  to impact behaviour of a dictionary.
132
132
 
133
133
  * `file_type` - a string that specifies the type of files used to store objects.
134
- Possible values are "json" and "pkl". Default value is "pkl".
134
+ Possible values are "json" and "lz4". Default value is "lz4".
135
135
  Storing objects as JSON files is mostly supported for debugging purposes.
136
136
  * `immutable_items` - a boolean that specifies whether items in a dictionary
137
137
  can be modified/deleted. It enables various distributed cache optimizations
138
138
  for remote storage. True means an append-only dictionary.
139
139
  False means normal dict-like behaviour. The default value is False.
140
- * `digest_len` - a length of a hash signature suffix which `persidict`
140
+ * `digest_len` - a length of a hash signature suffix which `PersiDict`
141
141
  automatically adds to each string in a key while mapping the key to
142
142
  the address of a value in a persistent storage backend
143
143
  (e.g. a filename or an S3 objectname). It is needed to ensure correct work
@@ -158,6 +158,7 @@ Binary installers for the latest released version are available at the Python pa
158
158
  ## Dependencies
159
159
 
160
160
  * [jsonpickle](https://jsonpickle.github.io)
161
+ * [joblib](https://joblib.readthedocs.io)
161
162
  * [pandas](https://pandas.pydata.org)
162
163
  * [numpy](https://numpy.org)
163
164
  * [boto3](https://boto3.readthedocs.io)
@@ -9,10 +9,9 @@ as a pickle or a json object in the file.
9
9
  from __future__ import annotations
10
10
 
11
11
  import os
12
- import pickle
13
12
  from typing import Any
14
13
 
15
-
14
+ import joblib
16
15
  import jsonpickle
17
16
  import jsonpickle.ext.numpy as jsonpickle_numpy
18
17
  import jsonpickle.ext.pandas as jsonpickle_pandas
@@ -39,7 +38,7 @@ class FileDirDict(PersiDict):
39
38
 
40
39
  def __init__(self
41
40
  , dir_name: str = "FileDirDict"
42
- , file_type: str = "pkl"
41
+ , file_type: str = "lz4"
43
42
  , immutable_items:bool = False
44
43
  , digest_len:int = 8):
45
44
  """A constructor defines location of the store and file format to use.
@@ -47,7 +46,7 @@ class FileDirDict(PersiDict):
47
46
  dir_name is a directory that will contain all the files in
48
47
  the FileDirDict. If the directory does not exist, it will be created.
49
48
 
50
- file_type can take one of two values: "pkl" or "json".
49
+ file_type can take one of two values: "lz4" or "json".
51
50
  It defines which file format will be used by FileDirDict
52
51
  to store values.
53
52
  """
@@ -57,8 +56,8 @@ class FileDirDict(PersiDict):
57
56
 
58
57
  self.file_type = file_type
59
58
 
60
- assert file_type in {"json", "pkl"}, (
61
- "file_type must be either pkl or json")
59
+ assert file_type in {"json", "lz4"}, (
60
+ "file_type must be either lz4 or json")
62
61
  assert not os.path.isfile(dir_name)
63
62
  if not os.path.isdir(dir_name):
64
63
  os.mkdir(dir_name)
@@ -144,27 +143,27 @@ class FileDirDict(PersiDict):
144
143
  def _read_from_file(self, file_name:str) -> Any:
145
144
  """Read a value from a file. """
146
145
 
147
- if self.file_type == "pkl":
146
+ if self.file_type == "lz4":
148
147
  with open(file_name, 'rb') as f:
149
- result = pickle.load(f)
148
+ result = joblib.load(f)
150
149
  elif self.file_type == "json":
151
150
  with open(file_name, 'r') as f:
152
151
  result = jsonpickle.loads(f.read())
153
152
  else:
154
- raise ValueError("file_type must be either pkl or json")
153
+ raise ValueError("file_type must be either lz4 or json")
155
154
  return result
156
155
 
157
156
  def _save_to_file(self, file_name:str, value:Any) -> None:
158
157
  """Save a value to a file. """
159
158
 
160
- if self.file_type == "pkl":
159
+ if self.file_type == "lz4":
161
160
  with open(file_name, 'wb') as f:
162
- pickle.dump(value, f)
161
+ joblib.dump(value, f, compress='lz4')
163
162
  elif self.file_type == "json":
164
163
  with open(file_name, 'w') as f:
165
164
  f.write(jsonpickle.dumps(value, indent=4))
166
165
  else:
167
- raise ValueError("file_type must be either pkl or json")
166
+ raise ValueError("file_type must be either lz4 or json")
168
167
 
169
168
  def __contains__(self, key:PersiDictKey) -> bool:
170
169
  """True if the dictionary has the specified key, else False. """
@@ -27,7 +27,7 @@ def _create_signature_suffix(input_str:str, digest_len:int) -> str:
27
27
  input_b = input_str.encode()
28
28
  hash_object = hashlib.md5(input_b)
29
29
  full_digest_str = base64.b32encode(hash_object.digest()).decode()
30
- suffix = "_" + full_digest_str[:digest_len]
30
+ suffix = "_" + full_digest_str[:digest_len].lower()
31
31
 
32
32
  return suffix
33
33
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: persidict
3
- Version: 0.2.5
3
+ Version: 0.3.1
4
4
  Summary: Simple persistent key-value store for Python. Values are stored as files on a disk or as S3 objects on AWS cloud.
5
5
  Home-page: https://github.com/vladlpavlov/persidict
6
6
  Author: Vlad (Volodymyr) Pavlov
@@ -18,6 +18,14 @@ Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
18
  Requires-Python: >=3.8
19
19
  Description-Content-Type: text/markdown
20
20
  License-File: LICENSE
21
+ Requires-Dist: lz4
22
+ Requires-Dist: joblib
23
+ Requires-Dist: numpy
24
+ Requires-Dist: pandas
25
+ Requires-Dist: jsonpickle
26
+ Requires-Dist: boto3
27
+ Requires-Dist: moto
28
+ Requires-Dist: pytest
21
29
 
22
30
  # persidict
23
31
 
@@ -143,8 +151,8 @@ that simultaneously work with the same instance of a dictionary.
143
151
  * Values must be pickleable Python objects.
144
152
  * Insertion order is not preserved.
145
153
  * You can not assign initial key-value pairs to a dictionary in its constructor.
146
- * Methods `delete_if_exists()`, `mtimestamp()`, `get_subdict()` and `subdicts()`
147
- are available
154
+ * `PersiDict` API has methods = `delete_if_exists()`, `mtimestamp()`,
155
+ `get_subdict()` and `subdicts()` , which are not available in Python dicts.
148
156
 
149
157
  ## Fine Tuning
150
158
 
@@ -152,13 +160,13 @@ are available
152
160
  to impact behaviour of a dictionary.
153
161
 
154
162
  * `file_type` - a string that specifies the type of files used to store objects.
155
- Possible values are "json" and "pkl". Default value is "pkl".
163
+ Possible values are "json" and "lz4". Default value is "lz4".
156
164
  Storing objects as JSON files is mostly supported for debugging purposes.
157
165
  * `immutable_items` - a boolean that specifies whether items in a dictionary
158
166
  can be modified/deleted. It enables various distributed cache optimizations
159
167
  for remote storage. True means an append-only dictionary.
160
168
  False means normal dict-like behaviour. The default value is False.
161
- * `digest_len` - a length of a hash signature suffix which `persidict`
169
+ * `digest_len` - a length of a hash signature suffix which `PersiDict`
162
170
  automatically adds to each string in a key while mapping the key to
163
171
  the address of a value in a persistent storage backend
164
172
  (e.g. a filename or an S3 objectname). It is needed to ensure correct work
@@ -179,6 +187,7 @@ Binary installers for the latest released version are available at the Python pa
179
187
  ## Dependencies
180
188
 
181
189
  * [jsonpickle](https://jsonpickle.github.io)
190
+ * [joblib](https://joblib.readthedocs.io)
182
191
  * [pandas](https://pandas.pydata.org)
183
192
  * [numpy](https://numpy.org)
184
193
  * [boto3](https://boto3.readthedocs.io)
@@ -1,3 +1,5 @@
1
+ lz4
2
+ joblib
1
3
  numpy
2
4
  pandas
3
5
  jsonpickle
@@ -5,7 +5,7 @@ with open("README.md", "r") as f:
5
5
 
6
6
  setuptools.setup(
7
7
  name="persidict"
8
- ,version="0.2.5"
8
+ ,version="0.3.1"
9
9
  ,author="Vlad (Volodymyr) Pavlov"
10
10
  ,author_email="vlpavlov@ieee.org"
11
11
  ,description= "Simple persistent key-value store for Python. "
@@ -28,7 +28,9 @@ setuptools.setup(
28
28
  ,keywords='persistence, dicts, distributed, parallel'
29
29
  ,python_requires='>=3.8'
30
30
  ,install_requires=[
31
- 'numpy'
31
+ 'lz4'
32
+ , 'joblib'
33
+ , 'numpy'
32
34
  , 'pandas'
33
35
  , 'jsonpickle'
34
36
  , 'boto3'
File without changes
File without changes