Details
Description
I'd like to make the Database and Collection objects hashable so that I can use them easily in caching mechanism.
For instance:
@functools.lru_cache |
def get_governor(database: pymongo.database.Database, state: str) -> Optional[str]:
|
officials = database.officials.find_one({'_id': state}) |
if not officials: |
return None |
return officials.get('governor') |
Today this is breaking because database is not hashable. It's not hashable because it has an _eq_ method but no _hash_ method.
Attachments
Issue Links
- is related to
-
MOTOR-781 Fix synchro test failures with PyMongo 3.12
-
- Closed
-
- related to
-
PYTHON-2471 Consider configuration option values when comparing/hashing instances of MongoClient, Database, Collection
-
- Backlog
-