Comparisons and sorting of a numeric class....
Terry Reedy
tjreedy at udel.edu
Fri Jan 23 17:17:52 CET 2015
On 1/23/2015 6:46 AM, Andrew Robinson wrote:
> -- because people seem to have a very wrong idea about bool's nature as
> a dualton being somehow justified solely by the fact that there are only
> two values in Boolean logic; For, singletons style programming is not
> justified by the number of values an object has in reality -- And I know
> Charles bool didn't use singletons in his algebra, -- just read his
> work and you'll see he never mentions them or describes them, but he
> does actually use dozens of *instances* of the True and False objects he
In mathematics, as conceived by most mathematicians, there is only one
instance of each immutable value. Value is identity. There is only one
immutable empty set. (This, without the assumed 'immutable' added, is a
quote from beginning set theory texts written to counteract the beginner
mistake, here repeated by you, of thinking that there might be more than
one.) There is only one 0, one 1, one (immutable) set {0, 1}, and one
one symbol 'a'. The notion of identity separate from value is only
needed for mutable objects, which generally do not appear in math. So
unless Boole was an oddball among mathematicians, he considered multiple
instances of the word 'True' to be multiple references to the one and
only logical value True.
In Python, any immutable instance *could be* a singleton. In current
CPython, the ints -10 to 256 *are* singletons. In 'x = 1 + 1', the two
1s are the same 1. Other ints are not made to be singletons only
because the cost would be greater than the benefit. Similarly, ascii
chars are singletons and some other strings are interned to make them
singletons. Also, the empty tuple is a singleton. Empty lists cannot
be because they are mutable and each instance must be separately mutable.
>>> x = 'a'; y = 'a'; x is y
True
>>> x = (); y = (); x is y
True
> was talking about -- for the obvious reason that he would have needed
> special mirrors, dichroic or partially silvered, to be even able to
> attempt to make one instance of True written on paper show up in
> multiple places;
This is engineer talk. From a mathematical point of view, the above is
nonsense. Math values are generally seen as timeless spaceless platonic
values.
--
Terry Jan Reedy
More information about the Python-list
mailing list