This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Add ability to freeze (seal) mutable objects
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.6
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: eric.smith, ppperry, socketpair
Priority: normal Keywords:

Created on 2016-05-20 21:52 by socketpair, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (7)
msg265965 - (view) Author: Марк Коренберг (socketpair) * Date: 2016-05-20 21:52
I mean making mutable object immutable. I speak about List(), Set(), bytearray(), memoryview(), mmap() and so on.

bytearray already have `hold`, to lock size only, but it still not represented in Python.
msg265972 - (view) Author: (ppperry) Date: 2016-05-20 23:05
Use tuples, frozensets, and bytes for the first three cases instead. I don't quite see what the benefit of this is. It seems arbitrarily restrictive.
msg265973 - (view) Author: Марк Коренберг (socketpair) * Date: 2016-05-20 23:13
making tuples (from lists), fronzensets(from sets) and bytes (from bytearray) requires memory copying. Especially for bytearrays.
msg265974 - (view) Author: (ppperry) Date: 2016-05-20 23:21
Python is not the type of language in which one applies such memory micro-optimizations. In any case, if you really need to do this, use a custom class that subclasses `list` and overrides the modification methods to add a check.
msg265976 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2016-05-20 23:25
See the rejected PEP 351:
msg265985 - (view) Author: Марк Коренберг (socketpair) * Date: 2016-05-21 04:34
Great. Do you have information why this PEP was rejected? This was exactly what I want.
msg265993 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2016-05-21 08:44
There's a link in the PEP to the discussion on why it was rejected. There's a lot to read in the thread (I just spent 30 minutes re-reading it!).

I'm going to close this. If you'd like to re-open the discussion with new insights, I'd suggest posting to python-ideas. But, given the existing discussion referenced by the PEP, I don't have high hopes, unless you have a compelling use case (which is always possible, of course).
Date User Action Args
2022-04-11 14:58:31adminsetgithub: 71257
2016-05-21 08:44:47eric.smithsetstatus: open -> closed
resolution: rejected
messages: + msg265993

stage: resolved
2016-05-21 04:34:46socketpairsetmessages: + msg265985
2016-05-20 23:25:48eric.smithsetnosy: + eric.smith
messages: + msg265976
2016-05-20 23:21:55ppperrysetmessages: + msg265974
2016-05-20 23:13:15socketpairsetmessages: + msg265973
2016-05-20 23:05:36ppperrysetnosy: + ppperry
messages: + msg265972
2016-05-20 21:52:33socketpaircreate