-
-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
implement stricter 1-to-1 checking #26
Changes from 16 commits
bbd2312
a0eac74
01c8d08
490b7f4
1f3a6a6
3625e08
139fbdd
ebff7c4
32ff4ae
3a38732
c23baf3
3c2bc1e
4446d57
2089b7b
fdcd458
9467752
4a629a9
de821e9
6e99c4a
b879d01
b5317be
dcba3ab
8bf9606
abeb01e
cf583b5
3d8bb18
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.10.0.dev | ||
0.10.0.dev0 |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from ._bidict import bidict | ||
|
||
class loosebidict(bidict): | ||
""" | ||
A mutable bidict which always uses forcing put operations | ||
so that it never raises :class:`ValueExistsException`. | ||
""" | ||
def _put(self, key, val): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tiny performance optimisation, but
would remove function call overhead without increasing code duplication. I imagine _put() will get called a lot in loops, so this adds up. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Originally had that but changed it in favor of dynamic method lookup for more extensibility. Worth it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right. We shouldn't make changes like this unless we've profiled what the possible speedups might be. |
||
return self.forceput(key, val) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it may now be sensible for
put()
to be the "non-overwriting set", rather than an alias for__setitem__
. For example,This closes off the case you struggle to explain in the Caveats docs, about how to insert an item without a risk of accidental overwrite on the key side as well as the value side. Meanwhile the
__setitem__
syntax on the forward and inverse bidicts allows overwrites on keys and values respectively, andforceput()
allows overrides from both ends.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another great suggestion. Implemented in de821e9.