question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Handle the iterator protocol properly in `st.cache`

See original GitHub issue

Summary

As part of our December plan to fix hashing, we are defining new hashing semantics. This issue covers step 3.

More background

This task is important becuase:

  1. It means we no longer have to special case lists and tuples.
  2. It is a prerequisite to enable hashing of other primitive types through default hash_funcs (INSERT LINK HERE).
  3. It allows the user to recursively hash container types.

Details

Step 3 states that we handle iterators properly.

Roughly the semantics are:

try:
    for elem in iter(x):
        hash(elem)
except (this iter thing failed):
    go onto step 4

Important Note: When this is done, we no longer need to special case lists and tuples!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
tvstcommented, Dec 13, 2019

Ok, we’ve made the following decision:

  • Let’s hash lists, tuples, and dicts
  • Let’s not hash other kinds of iterables. These should show the unhashable warning.
  • Let’s not hash generators. These should show the unhashable warning.
0reactions
treuillecommented, Dec 10, 2019

No. Not missing anything. Lemme think about this and get back to you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Optimize performance with st.cache - Streamlit Docs
We're developing new cache primitives that are easier to use and much faster than @st.cache . To learn more, read Experimental cache primitives....
Read more >
C++ and STL: Take Advantage of STL Algorithms by ...
In the iterator sample, I treat the cache as a read-only data structure in order to use several algorithms in the STL and...
Read more >
Set-Associative Cache - an overview | ScienceDirect Topics
An N-way set associative cache reduces conflicts by providing N blocks in each set where data mapping to that set might be found....
Read more >
Using Hot Rod Java clients - Infinispan
Hot Rod is a binary TCP client/server protocol that gives fast access ... Connect to the Infinispan cluster RemoteCacheManager cacheManager ...
Read more >
Caching in GitLab CI/CD
A cache is one or more files a job downloads and saves. ... During the caching process, there's also a couple of things...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found