Skip to content

Instantly share code, notes, and snippets.

@youknowone
Created Oct 22, 2019
Embed
What would you like to do?
import bson
import ring
oid1 = bson.objectid.ObjectId(b'foo-bar-quux')
oid2 = bson.objectid.ObjectId(b'foo-bar-quxy')
oidx = bson.objectid.ObjectId(b'foo-bar-quux')
assert oid1 == oidx
assert oid1 is not oidx
assert oid1 != oid2
@ring.lru()
def f(oid):
print('caching:', oid)
return oid
assert f(oid1) is oid1
assert f(oid2) is oid2
assert f(oidx) is oid1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment