-
-
Notifications
You must be signed in to change notification settings - Fork 62
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
Consider removing slice and ~ syntax #19
Comments
Thanks for opening this. Until now the feedback about the slice syntax has been unanimously positive, so it's valuable to hear another perspective. Eliminating the slice syntax would also allow me to get rid of the caveat about not being able to access a That said, before I remove one of bidict's most appealing features for so many users, I'd need to get more feedback in favor of this, ideally supported by empirical evidence that the sugar is doing harm. In the meantime, there's nothing stopping users who prefer to use |
The syntax isn't doing harm, but I feel (from experience) that it makes it less suitable for adoption in a large project. Clear, non magical APIs seem to be key to making Python scale to large codebases. Every caveat that a class brings in adds to the cognitive load. |
After sleeping on it, I'm reopening this. Dropping support for the slice syntax, as well as ~, seems like it could increase bidict's Python Zen on a few levels:
It would also make the code cleaner and easier to maintain. And being able to remove the "None value" caveat would be great. I spent some time on GitHub code search surveying usage of slice and ~ syntax. Here is a sample of people whose code would break if I remove the syntax:
Everyone please give feedback here, and please spread the word to other bidict users. I'm leaning toward going through with this, but if users' feedback trumps the rationale above, I won't. While we're at it, I'm also thinking of removing namedbidict. If you have any feedback on that, please chime in on #23. Thanks everyone. |
My project can easily be converted if you decide to change. I may just go ahead and do that preemptively. |
What would the syntax change to? cheers James Mills / prologic E: prologic@shortcircuit.net.au On Wed, Nov 25, 2015 at 10:38 AM, ajmarks notifications@github.com wrote:
|
@prologic You would use |
I see; thanks for that. I'm happy for this change to go ahead personally. I would however prefer something like |
Thanks @prologic, glad you're happy for this to go ahead. Changing to As for the callable rather than getitem syntax, again another breaking change, and harmfully masks the fact that |
FWIW, in my survey of bidict usage, I did encounter instances of people preferring to use |
Fair points :) Go for it! James Mills / prologic E: prologic@shortcircuit.net.au On Wed, Nov 25, 2015 at 11:30 AM, jab notifications@github.com wrote:
|
My project could also easily be changed to a new syntax, if required. |
Implemented this on a branch and opened a PR for it in #25. Please take a look and test if you can. |
+1 for removal. That said, the project's been around for a while, so introducing backwards-incompatible changes at this point might do more harm than good. |
My project could also easily be changed to a new syntax. Thanks. From Meizu MX4 -------- Original message --------
|
Thanks for the feedback, everyone. Just merged the branch that implements this. |
Ping this issue when you've pushed a new release to PyPi :) James Mills / prologic E: prologic@shortcircuit.net.au On Sat, Nov 28, 2015 at 5:23 AM, jab notifications@github.com wrote:
|
Will do. |
@prologic Released! |
👍 |
Unfortunately our system just used the latest version of bidict -- so our system died when 0.10 was released (we used the slice syntax). This (again) teaches us the importance of version locking... |
@pjsg Sorry to hear you got bit by the breaking changes. I hope the bugfixes and other improvements in 0.10+ make it worth upgrading. Btw, just invited you to join https://gitter.im/jab/bidict. I always ping everyone in there with news (and Gitter can email you messages you missed while not in the chat), in case you're interested. Please feel free to stop by and say hi / share your use case any time. |
I respect this decision. But it should warn |
@sublee Once bidict reaches 1.0, yes, but in the meantime, I'm following semver.org which says:
Hope that seems fair. FWIW, as of closing #23, I don't foresee making any further breaking changes before 1.0. My current thinking is bidict will be ready for 1.0 as soon I make sure that its performance is about equal to keeping 2 inverse dicts in sync manually (see #9). I may also add support for I invited you to join https://gitter.im/jab/bidict. As I said above, I always ping everyone in there with news (and Gitter can email you messages you missed while not in the chat), in case you're interested. Please feel free to stop by and say hi / share your use case any time. I love getting to know bidict's users better. |
@jab Thanks to good answer. Now I agree your thinking. |
Some of the syntactic sugar in bidict causes a readability problem for me. Syntactic sugar is always going to be subjective, but I'd like to propose the removal of the overloading of slicing and bitwise negation - because
.inv
is succinct and covers all these cases without needing the sugar:~d
is clearer written asd.inv
d[:key]
is clearer written asd.inv[key]
.These don't need to be explained/learned in the same way as they follow from the same clear rule.
Naturally this would be a big breaking change but if bidict is not yet at a 1.0 release then this could presumably still be considered.
The text was updated successfully, but these errors were encountered: