"Constant variables" is a contradiction in terms. If it is constant, it 
cannot be a variable, and vice versa. Can we be more precise in the 
language used please?

We have two independent concepts here:

* name bindings: names can be bound to a value, or unbound with 
  the `del` statement;

* values can be mutable or immutable.

"Constant" might refer to immutability. `1` is a constant, but `[]` is 
not, because the list can be mutated. In some languages (not Python), we 
can "freeze" a mutable object and turn it immutable.

Or it might refer to bindings: a perhaps a constant name cannot be 
unbound or rebound to a new object, but the object may be either mutable 
or immutable.

Can you explain what combination of these three features (binding of 
names, mutability of objects, a "freeze" protocol) you are looking for?

You say:

> Usually if we have a constant we don't create another reference to it. 
> So do not support two references. Why not? Many reasons, especially 
> deallocation problems.

That seems very odd. That would mean that you can't pass constants to 
functions, or put them in lists or dicts, since that would create new 
references to the object.

What if an object has already got more than one reference?

    >>> import gc
    >>> count = len(gc.get_referrers(None))
    >>> print(count)
    1771

With more than 1700 references to the None object, I guess we can't 
create a constant None. That's going to go straight into the list of 
Python WTFs. Small ints also have many references:

    >>> len(gc.get_referrers(1))
    65

I think people would be surprised if they can't make a constant 1. I 
know I would be.


-- 
Steve
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/CGFSWYONRHM65BY2NTYEJSUPSAUDMH63/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to