Replies: 1 comment
-
@wmjd Thanks for posting! Perhaps the interesting question here is for what values of n is it worth having a special-purpose library like bidict vs. using something like https://docs.python.org/3/library/sqlite3.html. As Raymond Hettinger once put it,
I think for n=2, bidict is usually a better fit than something like sqlite3, but I buy Raymond's view that as n increases, at a certain point, a database-shaped thing is the right solution at least for many use cases. P.S. I noticed your https://github.com/wmjd/TransitiveDictionary experiment -- fun :) |
Beta Was this translation helpful? Give feedback.
-
Have you considered a 1-to-1 mapping data structure between not just two, but any arbitrary number of domains? In the implementation I have roughly ideated, there are n backing dictionaries
D_1 -> D_2 -> … -> D_n -> D_1. Since function composition is a transitive relation, we can map into any domain from any domain in at most n-1 steps (but I think we still keep constant time lookups since the input size is maybe len(D_i) not n)
Perhaps this is a naive, wacky, or impractical idea. However, if you have any thoughts, I would be very happy to know them! I think bidict is super cool and I am, essentially, at your service :)
Beta Was this translation helpful? Give feedback.
All reactions