A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2001-January/012367.html below:

[Python-Dev] Making mutable objects readonly

[Python-Dev] Making mutable objects readonlyM.-A. Lemburg mal@lemburg.com
Wed, 31 Jan 2001 13:01:24 +0100
Guido van Rossum wrote:
> 
> [ESR]
> > For different reasons, I'd like to be able to set a constant flag on a
> > object instance.  Simple semantics: if you try to assign to a
> > member or method, it throws an exception.
> >
> > Application?  I have a large Python program that goes to a lot of effort
> > to build elaborate context structures in core.  It would be nice to know
> > they can't be even inadvertently trashed without throwing an exception I
> > can watch for.
> 
> Yes, this is a good thing.  Easy to do on lists and dicts.  Questions:
> 
> - How to spell it?  x.freeze()?  x.readonly()?

How about .lock() and .unlock() ?
 
> - Should this reversible?  I.e. should there be an x.unfreeze()?

Yes. These low-level locks could be used in thread programming
since the above calls are C level functions and thus thread safe
w/r to the global interpreter lock.
 
> - Should we support something like this for instances too?  Sometimes
>   it might be cool to be able to freeze changing attribute values...

Sure :)

Eric, could you write a PEP for this ?

-- 
Marc-Andre Lemburg
______________________________________________________________________
Company:                                        http://www.egenix.com/
Consulting:                                    http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4