[Python-ideas] Changing the meaning of bool.__invert__

Steven D'Aprano steve at pearwood.info
Sat Apr 9 11:25:14 EDT 2016


On Sat, Apr 09, 2016 at 08:28:10AM -0600, Ian Kelly wrote:

> It seems unusual to deprecate something without also providing a means
> of using the new thing in the same release. "Don't use this feature
> because we're going to change what it does in the future. Oh, you want
> to use the new version? Psych! We haven't actually done anything yet.
> Use not instead." It creates a weird void in Python 3.6 where the
> operator still exists but absolutely nobody has a legitimate reason to
> be using it.

Not really. This is quite similar to what happened in Python 2.3 during 
int/long unification. The behaviour of certain integer operations 
changed, including the meaning of some literals, and warnings were 
displayed.

I don't have 2.3 available to demonstrate but I can show you the change 
in behaviour:

[steve at ando ~]$ python1.5 -c "print 0xffffffff"
-1
[steve at ando ~]$ python2.4 -c "print 0xffffffff"
4294967295


By memory, 0xffffffff in python2.3 would print a warning that the result 
will change in the next release, and return -1.

See:

https://www.python.org/dev/peps/pep-0237/
https://www.python.org/download/releases/2.3.5/notes/



> What happens if somebody is using ~ for its current semantics, skips
> the 3.6 release in their upgrade path, and doesn't read the release
> notes carefully enough? They'll never see the warning and will just
> experience a silent and difficult-to-diagnose breakage.

Then they'll be in the same position as everybody if there's no 
depreciation at all.


-- 
Steve


More information about the Python-ideas mailing list