-
Notifications
You must be signed in to change notification settings - Fork 127
Deprecate use of .has_key() to follow modern Python #153
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
Conversation
Using the in operator is preferred and available on all supported versions of Python. From https://docs.python.org/3/whatsnew/3.0.html#builtins > Removed. dict.has_key() – use the in operator instead.
-1 I'm strictly against more deprecation warnings. They are a big impact on performance for no apparent benefit. It's very easy to grep for |
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.
-1 on more warnings, see #133
The benefit of warning in deprecated functions is to alert library users to change their code. Without this warning, they may not realize that a function is deprecated and will be removed. This helps to future proof their code to avoid breakage when they upgrade. Not all library users always read the documentation every release. Are you suggesting there is a performance impact when library users use the deprecated function only or even without using the deprecated function?. If you mean for the deprecated function only, then I don't see why that is an issue. Once library users change their code to not use the deprecated function, I imagine the performance impact will not exist.
I think keeping the warning will result in the best experience for library users such that it will result in the fewest surprises in the future. |
Deprecation warnings are not as helpful as you may think. Python doesn't show any deprecation warning unless user opts in explicitly. Neither library developers nor application developers will see the warning unless they run Python with extra arguments or enable warnings explicitly. For python-ldap's test suite, I have enabled warnings. CPython doesn't use standard warnings for
|
Deprecation warnings will actually be shown by default in some situations starting with Python 3.7. See https://bugs.python.org/issue31975. Many projects do run code with warnings enabled during tests or while developing. I agree, perhaps 100% of library users won't see all warnings. But I do think they're effective for disciplined developers and help alert them to necessary changes. It certainly helps me for the libraries I use in my projects. For those that do see them, it will help reduce breakage and remain forward compatible. Those that heed the warning will not have a performance impact. For example, Django uses deprecation warnings to great effect. The warnings displayed when running a Django application go a long way towards informing the developers what must change to be forward compatible.
If library users are using
python-ldap 2.x correctly specifies the |
If we are going to remove However, I don't think keeping Let's just document the functions as deprecated, and say we won't remove them in the foreseeable future. Does that sound reasonable? |
Using the in operator is preferred and available on all supported
versions of Python.
From https://docs.python.org/3/whatsnew/3.0.html#builtins