Skip to content

Instantly share code, notes, and snippets.

Created Oct 22, 2019
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
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