A RetroSearch Logo

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

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2012-March/117298.html below:

[Python-Dev] PEP 416: Add a frozendict builtin type

[Python-Dev] PEP 416: Add a frozendict builtin type [Python-Dev] PEP 416: Add a frozendict builtin typeVictor Stinner victor.stinner at gmail.com
Sun Mar 4 00:11:25 CET 2012
Le 29/02/2012 19:21, Victor Stinner a écrit :
> Rationale
> =========
>
> (...) Use cases of frozendict: (...)

I updated the PEP to list use cases described in the other related 
mailing list thread.
---
Use cases:

  * frozendict lookup can be done at compile time instead of runtime 
because the mapping is read-only. frozendict can be used instead of a 
preprocessor to remove conditional code at compilation, like code 
specific to a debug build.
  * hashable frozendict can be used as a key of a mapping or as a member 
of set. frozendict can be used to implement a cache.
  * frozendict avoids the need of a lock when the frozendict is shared 
by multiple threads or processes, especially hashable frozendict. It 
would also help to prohibe coroutines (generators + greenlets) to modify 
the global state.
  * frozendict helps to implement read-only object proxies for security 
modules. For example, it would be possible to use frozendict type for 
__builtins__ mapping or type.__dict__. This is possible because 
frozendict is compatible with the PyDict C API.
  * frozendict avoids the need of a read-only proxy in some cases. 
frozendict is faster than a proxy because getting an item in a 
frozendict is a fast lookup whereas a proxy requires a function call.
  * use a frozendict as the default value of function argument: avoid 
the problem of mutable default argument.
---

Victor
More information about the Python-Dev mailing list

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