Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

francois-durand
Copy link

Hi @pydanny,

Thank you for this package! This pull request addresses issues #32 and #196. Here is a sum-up:

  • All cached properties derive from a parent class CachedProperty, so that we can use isinstance to identify them easily.
  • Add function cached_properties: iterate over the cached properties of an object.
  • Add function is_cached: whether a cached property is already cached.
  • Add function un_cache: empty the cache for a cached property. As @Tinche noted, it avoids exposing an implementation detail.
  • Add function delete_cache: empty the whole cache of an object.
  • Add decorator property_deleting_cache: a property that deletes the cache when it is set or deleted. A typical example of application is given in the docstring (and in the readme).

For property_deleting_cache, some people may find it strange to have this parameter func whose output is ignored. As a matter of fact, in most use cases, I guess that its code will be pass. I hesitated a bit and I also implemented another syntax option in property_deleting_cache_2. However, I still prefer option 1 because its usage as a decorator is more similar to what we use for regular properties and cached properties. Tell me which one you prefer (and just remove the other one)!

In the readme, I suggest replacing the running example about monopoly by a more generic example. This monopoly example seemed quite unnatural to me, and I hope that the new one is more telling, even if it is a bit less funny.

This is my first pull request ever so do not hesitate to tell me if I did something wrong :-). Best,

François

* All cached properties derive from a parent class ``CachedProperty``, so that we can use isinstance to identify them.
* Add function ``cached_properties``: iterate over the cached properties of an object.
* Add function ``cached_properties_computed``: iterate over the cached properties that are already computed.
* Add function ``delete_cache``: empty the whole cache of an object.
* Add decorator ``property_deleting_cache``: a property that deletes the cache when it is set or deleted.
* Use Black.
* ``property_deleting_cache`` uses the function for its side effects, even if its return value is ignored.
* ``property_deleting_cache_2``: proposition or alternate syntax.
* Remove ``cached_properties_computed``, because it is now a trivial combination of ``cached_properties`` and ``is_cached``.
* Update Readme:
  * Add new functions (un_cache, delete_cache, etc.).
  * Replace the monopoly running example by a more generic example.
* Add a notebook "readme companion" to test the code of the readme.
@francois-durand
Copy link
Author

No reaction? :'-(

@francois-durand
Copy link
Author

Bump.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.