frozendict

88888 Dihedral dihedral88888 at googlemail.com
Sat Feb 11 06:52:59 CET 2012


在 2012年2月11日星期六UTC+8上午2时57分34秒,John Nagle写道:
> On 2/10/2012 10:14 AM, Nathan Rice wrote:
> >>> Lets also not forget that knowing an object is immutable lets you do a
> >>> lot of optimizations; it can be inlined, it is safe to convert to a
> >>> contiguous block of memory and stuff in cache, etc.  If you know the
> >>> input to a function is guaranteed to be frozen you can just go crazy.
> >>> Being able to freeze(anyobject) seems like a pretty clear win.
> >>> Whether or not it is pythonic is debatable.  I'd argue if the meaning
> >>> of pythonic in some context is limiting, we should consider updating
> >>> the term rather than being dogmatic.
> 
>      A real justification for the ability to make anything immutable is
> to make it safely shareable between threads.  If it's immutable, it
> doesn't have to be locked for access.  Mozilla's new "Rust"
> language takes advantage of this.  Take a look at Rust's concurrency
> semantics.  They've made some progress.
> 
> 					John Nagl


Lets model the system as an asynchronous set of objects with multiple threads
performing operatons on objects as in the above.

This reminds me  the old problem solved before in the digital hardware. 



More information about the Python-list mailing list