evalcache 1.13.0__tar.gz → 1.15.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.
@@ -0,0 +1,83 @@
1
+ Metadata-Version: 2.4
2
+ Name: evalcache
3
+ Version: 1.15.0
4
+ Summary: Lazy computing tree cache library
5
+ Home-page: https://github.com/mirmik/evalcache
6
+ Author: mirmik
7
+ Author-email: mirmikns@yandex.ru
8
+ License: MIT
9
+ Keywords: caching,lazy
10
+ Description-Content-Type: text/markdown
11
+ Dynamic: author
12
+ Dynamic: author-email
13
+ Dynamic: description
14
+ Dynamic: description-content-type
15
+ Dynamic: home-page
16
+ Dynamic: keywords
17
+ Dynamic: license
18
+ Dynamic: summary
19
+
20
+ # EvalCache
21
+ Lazy tree evaluation cache library.
22
+
23
+ ![](https://travis-ci.com/mirmik/evalcache.svg?branch=master)
24
+
25
+ ## Brief
26
+ The library implements a cache of dependent lazy calculations for working with clean, time-consuming computational tasks, such as symbolic transformations, geometric, numerical algorithms.
27
+
28
+ The task of the library is to save the result of the computation once performed and, if necessary, load it, saving the computing resources. The algorithm for constructing the hashkey of the computed object uses the input data parameterizing this object, which makes it possible to track changes in the arguments of the lazy algorithm and to postpone the necessary calculations if the conditions have changed. If an lazy object is used as an argument or a generating function, its hashkey is used as its hash. This allows you to build a dependent computational tree. If the input data of an object changes, its hashkey and hashkeys of all objects computed on its basis change. And the subtree will be reevaluated.
29
+
30
+ Since the library saves every computed object in the cache, including intermediate objects, it can pick up changes in the calculation tree from any step. Thus, previously received data, if they can be applied to a new calculation tree, will be used. This allows you to not make heavy preliminary calculations in separate files, and load them transparently, and also compare results with small changes in input parameters without multiple results remaking.
31
+
32
+ ## Install
33
+ ```sh
34
+ python3 -m pip install evalcache
35
+ ```
36
+
37
+ ## Details
38
+ ### Base example
39
+ ```python
40
+ import evalcache
41
+
42
+ lazy = evalcache.Lazy(cache = evalcache.DirCache(".evalcache"))
43
+
44
+ @lazy
45
+ def func(a,b,c):
46
+ return do_something(a,b,c)
47
+
48
+ lazyresult = func(1,2,3)
49
+ result = lazyresult.unlazy() #alternative: result = evalcache.unlazy(lazyresult)
50
+ ```
51
+
52
+ In that example we can see based classes and objects:
53
+ You should instance "evalcache.Lazy" for start work. "Lazy" get "cache" as parametr. Cache is a dict-like object those will store and load our evaluation's results. "Lazy" instance "lazy" can be used as decorator for create "LazyObjects". Decorated object "func" is a LazyObject. "func" can generate another lazyobject, as "lazyresult", for example with callable interface. For get evaluation result we use "unlazy" method.
54
+
55
+ ### Diagnostic
56
+ We can visualize cache operations:
57
+ ```python
58
+ lazy = evalcache.Lazy(cache = cache, diag = True)
59
+ ```
60
+ in this mode, when you use unlazy, you will see console output:
61
+ endp - get endpoint object.
62
+ fget - get variable from local object store.
63
+ load - get early stored value from cache.
64
+ save - evaluation executed and value stored.
65
+ eval - evaluated without storing
66
+
67
+ ### Hash algorithm
68
+ You can choose algorithm from hashlib or specify user's hashlib-like algorithm.
69
+ ```python
70
+ lazy = evalcache.Lazy(cache = cache, algo = hashlib.sha512)
71
+ ```
72
+
73
+ ### DirCache
74
+ DirCache is a dict-like object that used pickle to store values in key-named files.
75
+ It very simple cache and it can be changed to more progressive option if need.
76
+ ```python
77
+ lazy = evalcache.Lazy(cache = evalcache.DirCache(".evalcache"))
78
+ ```
79
+ ### Articles
80
+ [Дисковое кэширование деревьев ленивых вычислений](https://habr.com/post/422937/)
81
+
82
+ ### Contact
83
+ mirmik(mirmikns@yandex.ru)
@@ -54,6 +54,7 @@ class Lazy:
54
54
  algo=hashlib.sha256,
55
55
  encache=True,
56
56
  decache=True,
57
+ cached=None,
57
58
  onplace=False,
58
59
  onuse=False,
59
60
  fastdo=False,
@@ -69,6 +70,10 @@ class Lazy:
69
70
  status_notify=False,
70
71
  pedantic=False
71
72
  ):
73
+ if cached is not None:
74
+ encache = cached
75
+ decache = cached
76
+
72
77
  self.pedantic = pedantic
73
78
  self.cache = cache
74
79
  self.algo = algo
@@ -295,6 +300,7 @@ class LazyObject(object, metaclass=MetaLazyObject):
295
300
  kwargs={},
296
301
  encache=None,
297
302
  decache=None,
303
+ cached=None,
298
304
  onuse=None,
299
305
  value=None,
300
306
  hint=None,
@@ -303,6 +309,10 @@ class LazyObject(object, metaclass=MetaLazyObject):
303
309
  prevent_unwrap=None,
304
310
  prevent_unwrap_in_child=None
305
311
  ):
312
+ if cached is not None:
313
+ encache = cached
314
+ decache = cached
315
+
306
316
  self.__lazybase__ = lazifier
307
317
  self.__encache__ = encache if encache is not None else self.__lazybase__.encache
308
318
  self.__decache__ = decache if decache is not None else self.__lazybase__.decache
@@ -598,7 +608,7 @@ class NoExpand:
598
608
 
599
609
 
600
610
  def lazyinvoke(
601
- obj, generic, args=[], kwargs={}, encache=None, decache=None, cls=LazyObject, prevent=None
611
+ obj, generic, args=[], kwargs={}, encache=None, decache=None, cls=LazyObject, prevent=None, cached=None
602
612
  ):
603
613
  """Логика порождающего вызова.
604
614
 
@@ -606,6 +616,10 @@ def lazyinvoke(
606
616
  В независимости от необходимости мгновенного раскрытия создаётся ленивый
607
617
  объект, чтобы задействовать логику кэша."""
608
618
 
619
+ if cached is not None:
620
+ encache=cached
621
+ decache=cached
622
+
609
623
  if obj.__lazybase__.print_invokes:
610
624
  print("__lazyinvoke__", generic, args, kwargs)
611
625
 
@@ -0,0 +1,83 @@
1
+ Metadata-Version: 2.4
2
+ Name: evalcache
3
+ Version: 1.15.0
4
+ Summary: Lazy computing tree cache library
5
+ Home-page: https://github.com/mirmik/evalcache
6
+ Author: mirmik
7
+ Author-email: mirmikns@yandex.ru
8
+ License: MIT
9
+ Keywords: caching,lazy
10
+ Description-Content-Type: text/markdown
11
+ Dynamic: author
12
+ Dynamic: author-email
13
+ Dynamic: description
14
+ Dynamic: description-content-type
15
+ Dynamic: home-page
16
+ Dynamic: keywords
17
+ Dynamic: license
18
+ Dynamic: summary
19
+
20
+ # EvalCache
21
+ Lazy tree evaluation cache library.
22
+
23
+ ![](https://travis-ci.com/mirmik/evalcache.svg?branch=master)
24
+
25
+ ## Brief
26
+ The library implements a cache of dependent lazy calculations for working with clean, time-consuming computational tasks, such as symbolic transformations, geometric, numerical algorithms.
27
+
28
+ The task of the library is to save the result of the computation once performed and, if necessary, load it, saving the computing resources. The algorithm for constructing the hashkey of the computed object uses the input data parameterizing this object, which makes it possible to track changes in the arguments of the lazy algorithm and to postpone the necessary calculations if the conditions have changed. If an lazy object is used as an argument or a generating function, its hashkey is used as its hash. This allows you to build a dependent computational tree. If the input data of an object changes, its hashkey and hashkeys of all objects computed on its basis change. And the subtree will be reevaluated.
29
+
30
+ Since the library saves every computed object in the cache, including intermediate objects, it can pick up changes in the calculation tree from any step. Thus, previously received data, if they can be applied to a new calculation tree, will be used. This allows you to not make heavy preliminary calculations in separate files, and load them transparently, and also compare results with small changes in input parameters without multiple results remaking.
31
+
32
+ ## Install
33
+ ```sh
34
+ python3 -m pip install evalcache
35
+ ```
36
+
37
+ ## Details
38
+ ### Base example
39
+ ```python
40
+ import evalcache
41
+
42
+ lazy = evalcache.Lazy(cache = evalcache.DirCache(".evalcache"))
43
+
44
+ @lazy
45
+ def func(a,b,c):
46
+ return do_something(a,b,c)
47
+
48
+ lazyresult = func(1,2,3)
49
+ result = lazyresult.unlazy() #alternative: result = evalcache.unlazy(lazyresult)
50
+ ```
51
+
52
+ In that example we can see based classes and objects:
53
+ You should instance "evalcache.Lazy" for start work. "Lazy" get "cache" as parametr. Cache is a dict-like object those will store and load our evaluation's results. "Lazy" instance "lazy" can be used as decorator for create "LazyObjects". Decorated object "func" is a LazyObject. "func" can generate another lazyobject, as "lazyresult", for example with callable interface. For get evaluation result we use "unlazy" method.
54
+
55
+ ### Diagnostic
56
+ We can visualize cache operations:
57
+ ```python
58
+ lazy = evalcache.Lazy(cache = cache, diag = True)
59
+ ```
60
+ in this mode, when you use unlazy, you will see console output:
61
+ endp - get endpoint object.
62
+ fget - get variable from local object store.
63
+ load - get early stored value from cache.
64
+ save - evaluation executed and value stored.
65
+ eval - evaluated without storing
66
+
67
+ ### Hash algorithm
68
+ You can choose algorithm from hashlib or specify user's hashlib-like algorithm.
69
+ ```python
70
+ lazy = evalcache.Lazy(cache = cache, algo = hashlib.sha512)
71
+ ```
72
+
73
+ ### DirCache
74
+ DirCache is a dict-like object that used pickle to store values in key-named files.
75
+ It very simple cache and it can be changed to more progressive option if need.
76
+ ```python
77
+ lazy = evalcache.Lazy(cache = evalcache.DirCache(".evalcache"))
78
+ ```
79
+ ### Articles
80
+ [Дисковое кэширование деревьев ленивых вычислений](https://habr.com/post/422937/)
81
+
82
+ ### Contact
83
+ mirmik(mirmikns@yandex.ru)
@@ -5,7 +5,7 @@ import evalcache
5
5
 
6
6
  setup(
7
7
  name="evalcache",
8
- version="1.13.0",
8
+ version="1.15.0",
9
9
  packages=["evalcache"],
10
10
  author="mirmik",
11
11
  author_email="mirmikns@yandex.ru",
evalcache-1.13.0/PKG-INFO DELETED
@@ -1,76 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: evalcache
3
- Version: 1.13.0
4
- Summary: Lazy computing tree cache library
5
- Home-page: https://github.com/mirmik/evalcache
6
- Author: mirmik
7
- Author-email: mirmikns@yandex.ru
8
- License: MIT
9
- Description: # EvalCache
10
- Lazy tree evaluation cache library.
11
-
12
- ![](https://travis-ci.com/mirmik/evalcache.svg?branch=master)
13
-
14
- ## Brief
15
- The library implements a cache of dependent lazy calculations for working with clean, time-consuming computational tasks, such as symbolic transformations, geometric, numerical algorithms.
16
-
17
- The task of the library is to save the result of the computation once performed and, if necessary, load it, saving the computing resources. The algorithm for constructing the hashkey of the computed object uses the input data parameterizing this object, which makes it possible to track changes in the arguments of the lazy algorithm and to postpone the necessary calculations if the conditions have changed. If an lazy object is used as an argument or a generating function, its hashkey is used as its hash. This allows you to build a dependent computational tree. If the input data of an object changes, its hashkey and hashkeys of all objects computed on its basis change. And the subtree will be reevaluated.
18
-
19
- Since the library saves every computed object in the cache, including intermediate objects, it can pick up changes in the calculation tree from any step. Thus, previously received data, if they can be applied to a new calculation tree, will be used. This allows you to not make heavy preliminary calculations in separate files, and load them transparently, and also compare results with small changes in input parameters without multiple results remaking.
20
-
21
- ## Install
22
- ```sh
23
- python3 -m pip install evalcache
24
- ```
25
-
26
- ## Details
27
- ### Base example
28
- ```python
29
- import evalcache
30
-
31
- lazy = evalcache.Lazy(cache = evalcache.DirCache(".evalcache"))
32
-
33
- @lazy
34
- def func(a,b,c):
35
- return do_something(a,b,c)
36
-
37
- lazyresult = func(1,2,3)
38
- result = lazyresult.unlazy() #alternative: result = evalcache.unlazy(lazyresult)
39
- ```
40
-
41
- In that example we can see based classes and objects:
42
- You should instance "evalcache.Lazy" for start work. "Lazy" get "cache" as parametr. Cache is a dict-like object those will store and load our evaluation's results. "Lazy" instance "lazy" can be used as decorator for create "LazyObjects". Decorated object "func" is a LazyObject. "func" can generate another lazyobject, as "lazyresult", for example with callable interface. For get evaluation result we use "unlazy" method.
43
-
44
- ### Diagnostic
45
- We can visualize cache operations:
46
- ```python
47
- lazy = evalcache.Lazy(cache = cache, diag = True)
48
- ```
49
- in this mode, when you use unlazy, you will see console output:
50
- endp - get endpoint object.
51
- fget - get variable from local object store.
52
- load - get early stored value from cache.
53
- save - evaluation executed and value stored.
54
- eval - evaluated without storing
55
-
56
- ### Hash algorithm
57
- You can choose algorithm from hashlib or specify user's hashlib-like algorithm.
58
- ```python
59
- lazy = evalcache.Lazy(cache = cache, algo = hashlib.sha512)
60
- ```
61
-
62
- ### DirCache
63
- DirCache is a dict-like object that used pickle to store values in key-named files.
64
- It very simple cache and it can be changed to more progressive option if need.
65
- ```python
66
- lazy = evalcache.Lazy(cache = evalcache.DirCache(".evalcache"))
67
- ```
68
- ### Articles
69
- [Дисковое кэширование деревьев ленивых вычислений](https://habr.com/post/422937/)
70
-
71
- ### Contact
72
- mirmik(mirmikns@yandex.ru)
73
-
74
- Keywords: caching,lazy
75
- Platform: UNKNOWN
76
- Description-Content-Type: text/markdown
@@ -1,76 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: evalcache
3
- Version: 1.13.0
4
- Summary: Lazy computing tree cache library
5
- Home-page: https://github.com/mirmik/evalcache
6
- Author: mirmik
7
- Author-email: mirmikns@yandex.ru
8
- License: MIT
9
- Description: # EvalCache
10
- Lazy tree evaluation cache library.
11
-
12
- ![](https://travis-ci.com/mirmik/evalcache.svg?branch=master)
13
-
14
- ## Brief
15
- The library implements a cache of dependent lazy calculations for working with clean, time-consuming computational tasks, such as symbolic transformations, geometric, numerical algorithms.
16
-
17
- The task of the library is to save the result of the computation once performed and, if necessary, load it, saving the computing resources. The algorithm for constructing the hashkey of the computed object uses the input data parameterizing this object, which makes it possible to track changes in the arguments of the lazy algorithm and to postpone the necessary calculations if the conditions have changed. If an lazy object is used as an argument or a generating function, its hashkey is used as its hash. This allows you to build a dependent computational tree. If the input data of an object changes, its hashkey and hashkeys of all objects computed on its basis change. And the subtree will be reevaluated.
18
-
19
- Since the library saves every computed object in the cache, including intermediate objects, it can pick up changes in the calculation tree from any step. Thus, previously received data, if they can be applied to a new calculation tree, will be used. This allows you to not make heavy preliminary calculations in separate files, and load them transparently, and also compare results with small changes in input parameters without multiple results remaking.
20
-
21
- ## Install
22
- ```sh
23
- python3 -m pip install evalcache
24
- ```
25
-
26
- ## Details
27
- ### Base example
28
- ```python
29
- import evalcache
30
-
31
- lazy = evalcache.Lazy(cache = evalcache.DirCache(".evalcache"))
32
-
33
- @lazy
34
- def func(a,b,c):
35
- return do_something(a,b,c)
36
-
37
- lazyresult = func(1,2,3)
38
- result = lazyresult.unlazy() #alternative: result = evalcache.unlazy(lazyresult)
39
- ```
40
-
41
- In that example we can see based classes and objects:
42
- You should instance "evalcache.Lazy" for start work. "Lazy" get "cache" as parametr. Cache is a dict-like object those will store and load our evaluation's results. "Lazy" instance "lazy" can be used as decorator for create "LazyObjects". Decorated object "func" is a LazyObject. "func" can generate another lazyobject, as "lazyresult", for example with callable interface. For get evaluation result we use "unlazy" method.
43
-
44
- ### Diagnostic
45
- We can visualize cache operations:
46
- ```python
47
- lazy = evalcache.Lazy(cache = cache, diag = True)
48
- ```
49
- in this mode, when you use unlazy, you will see console output:
50
- endp - get endpoint object.
51
- fget - get variable from local object store.
52
- load - get early stored value from cache.
53
- save - evaluation executed and value stored.
54
- eval - evaluated without storing
55
-
56
- ### Hash algorithm
57
- You can choose algorithm from hashlib or specify user's hashlib-like algorithm.
58
- ```python
59
- lazy = evalcache.Lazy(cache = cache, algo = hashlib.sha512)
60
- ```
61
-
62
- ### DirCache
63
- DirCache is a dict-like object that used pickle to store values in key-named files.
64
- It very simple cache and it can be changed to more progressive option if need.
65
- ```python
66
- lazy = evalcache.Lazy(cache = evalcache.DirCache(".evalcache"))
67
- ```
68
- ### Articles
69
- [Дисковое кэширование деревьев ленивых вычислений](https://habr.com/post/422937/)
70
-
71
- ### Contact
72
- mirmik(mirmikns@yandex.ru)
73
-
74
- Keywords: caching,lazy
75
- Platform: UNKNOWN
76
- Description-Content-Type: text/markdown
File without changes
File without changes
File without changes