"Immutable", like C. Not rebound has another keyword, in Java for example (final). If we want to only avoid rebounding, I think const will be a bit confusing for C/C++ people.
(I wrote "immutable" because in C constness can be removed)
On Tue, 1 Dec 2020 at 01:12, Chris Angelico email@example.com wrote:
On Tue, Dec 1, 2020 at 10:25 AM Marco Sulla Marco.Sulla.Python@gmail.com wrote:
On Mon, 30 Nov 2020 at 23:26, David Mertz firstname.lastname@example.org wrote:
Somehow "dire" doesn't strike me as the right word.... Maybe you were looking for "conceivably useful in niche cases."?
Well, I think const can be useful for:
- multiprocessing. Now, for example, dict is passed between processes
using MappingProxyType, which is slow.
- avoid side effects. I expect that my object will not change and I
want to be sure I'll not change it by mistake. Mistake that I made a lot of times.
- contract. A function marks a parameter as const will guarantee that
the object will not be changed. It's something complementar to annotations.
- possible future speed improvements. For example, if an iterable is
const, you can skip a lot of checks about mutability on iteration and make it more fast.
Are you assuming that "const" means "will not be rebound" or "is immutable"? Or both?
ChrisA _______________________________________________ Python-ideas mailing list -- email@example.com To unsubscribe send an email to firstname.lastname@example.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://email@example.com/message/YFDQCV... Code of Conduct: http://python.org/psf/codeofconduct/