Notice: While JavaScript is not essential for this website, your interaction with the content will be limited. Please turn JavaScript on for the full experience.
...hashing modules should present the same interface. Additional methods or variables can be added, but those described in this document should always be present. Hash function modules define one function: new([string]) (unkeyed hashes) new([key] , [string]) (keyed hashes) Create a new hashing object and return it. The first form is for hashes that are unkeyed, such as MD5 or SHA. For keyed hashes such as HMAC, key is a required parameter containing a string giving the key to us...
...hash-algorithm=fnv. The value Py_HASH_EXTERNAL allows 3rd parties to provide their own implementation at compile time. Implementation: #if Py_HASH_ALGORITHM == Py_HASH_EXTERNAL extern PyHash_FuncDef PyHash_Func; #elif Py_HASH_ALGORITHM == Py_HASH_SIPHASH24 static PyHash_FuncDef PyHash_Func = {siphash24, "siphash24", 64, 128}; #elif Py_HASH_ALGORITHM == Py_HASH_FNV static PyHash_FuncDef PyHash_Func = {fnv, "fnv", 8 * sizeof(Py_hash_t), 16 * sizeof(Py_hash_t)}...
...hashing algorithm. The name should be a suitable parameter for hashlib.new. Hashing objects require the following methods: copy() Return a separate copy of this hashing object. An update to this copy won't affect the original object. digest() Return the hash value of this hashing object as a bytes containing 8-bit data. The object is not altered in any way by this function; you can continue updating the object after calling this function. hexdigest() Return the hash value of this hashing obj...
...hash-based pycs with and without the check_source bit set. --invalidation-mode will be a tristate option taking values timestamp (the default), checked-hash, and unchecked-hash corresponding to the values of PycInvalidationMode. importlib.util will be extended with a source_hash(source) function that computes the hash used by the pyc writing code for a bytestring source. Runtime configuration of hash-based pyc invalidation will be facilitated by a new --check-hash-based-pycs interpreter option. ...
...function or class. A function object contains a reference to the function's 'globals' object, which is the __dict__ of the module that defines it. Since the __dict__ normally has a reference to the function there's a cycle that needs to be broken, or else the __dict__ would never be garbage collected. Note that a reference-count based solution doesn't work within one module, since references between functions are by name, not by value -- two mutually recursive functions can still bot...
...function call. Constraints frozendict has to implement the Mapping abstract base class frozendict keys and values can be unorderable a frozendict is hashable if all keys and values are hashable frozendict hash does not depend on the items creation order Implementation Add a PyFrozenDictObject structure based on PyDictObject with an extra "Py_hash_t hash;" field frozendict.__hash__() is implemented using hash(frozenset(self.items())) and caches the result in its private hash attribute Reg...
...hash(d) Traceback (most recent call last): File "<stdin>", line 1, in ? TypeError: dict objects are unhashable >>> hash(freeze(d)) -1210776116 >>> {d: 4} Traceback (most recent call last): File "<stdin>", line 1, in ? TypeError: dict objects are unhashable >>> {freeze(d): 4} {{'a': 7, 'c': 9, 'b': 8}: 4} Reference implementation Patch 1335812 provides the C implementation of this feature. It adds the freeze() built-in, along with implementations of ...
...hashable (in which case hash() raises an exception), school Ib requires catching the hash() failure and falling back to an if/elif chain. School II simply lets the exception happen. The problem with catching an exception in hash() as required by school Ib, is that this may hide a genuine bug. A possible way out is to only use a dispatch dict if all case expressions are ints, strings or other built-ins with known good hash behavior, and to only attempt to hash the switch expression if it is al...
...hash secret from non-blocking system urandom: _PyRandom_Init() is modified to call _PyOS_URandom_Nonblocking(). random.Random constructor now uses non-blocking system urandom: it is modified to use internally the new _PyOS_URandom_Nonblocking() function to seed the RNG. Add a new os.getrandom() function A new os.getrandom(size, flags=0) function is added: use getrandom() syscall on Linux and getrandom() C function on Solaris. The function comes with 2 new flags: os.GRND_RANDOM: read bytes fr...
...hash of the file's contents. Notice that pyc and pyo generated files don't have any hash because they are automatically produced from py files. So checking the hash of the corresponding py file is enough to decide if the file and its associated pyc or pyo files have changed. The hash is either the empty string or the hash algorithm as named in hashlib.algorithms_guaranteed, followed by the equals character =, followed by the urlsafe-base64-nopad encoding of the digest (base64.urlsafe_b64encode(d...
...Hashing frozenmap instances can be hashable just like tuple objects: hash(frozenmap(foo='bar')) # works hash(frozenmap(foo=[])) # will throw an error Typing It is possible to use the standard typing notation for frozenmaps: m: frozenmap[str, int] = frozenmap() Implementation The proposed frozenmap immutable type uses a Hash Array Mapped Trie (HAMT) data structure. Functional programming languages, like Clojure, use HAMT to efficiently implement immutable hash tab...
...Hashing frozenmap instances can be hashable just like tuple objects: hash(frozenmap(foo='bar')) # works hash(frozenmap(foo=[])) # will throw an error Typing It is possible to use the standard typing notation for frozenmaps: m: frozenmap[str, int] = frozenmap() Implementation The proposed frozenmap immutable type uses a Hash Array Mapped Trie (HAMT) data structure. Functional programming languages, like Clojure, use HAMT to efficiently implement immutable hash tables, vectors, and s...
...hash__ the behavior when adding __hash__ is modified. An explicitly defined __hash__ is defined when: __eq__ is defined in the class and __hash__ is defined with any value other than None. __eq__ is defined in the class and any non-None __hash__ is defined. __eq__ is not defined on the class, and any __hash__ is defined. If unsafe_hash is true and an explicitly defined __hash__ is present, then ValueError is raised. If unsafe_hash is false and an explicitly defined __hash__ is present, then...
...hash mapping names of C source files (each containing a Python extension module) to a nested hash of information about how to build that module. The allowed keys to this nested hash are: - other_c: other C files that must be compiled and linked with the main C file to create the module - c_libraries: C libraries that must be included in the link ... """ No doubt the ext_modules nested hashes would have more options, a...
Version: None
Released: Oct. 4, 2014
This is a security-fix source-only release. The last binary release was 3.3.5. The list of fixed security related issues can be found in the NEWS file. Major new features of the 3.3 series, compared to 3.2 Python 3.3 includes a range of improvements of the 3.x series, as …
View Release Notes
Released: Oct. 12, 2014
Python 3.3.x has reached end-of-life. Python 3.3.7, the final security-fix release, is available here. This is a security-fix source-only release. The list of fixed security related issues can be found in the NEWS file. Major new features of the 3.3 series, compared to 3.2 Python 3.3 includes a …
...HASHSEED processing with a different data source, the following helper function will be added to the C API: int Py_ReadHashSeed(char *seed_text, int *use_hash_seed, unsigned long *hash_seed); This function accepts a seed string in seed_text and converts it to the appropriate flag and seed values. If seed_text is NULL, the empty string or the value "random", both use_hash_seed and hash_seed will be set to zero. Otherwise, use_hash_seed will be set to 1 an...
...hash in the form of a URL fragment with the following syntax: #<hashname>=<hashvalue>, where <hashname> is the lowercase name of the hash function (such as sha256) and <hashvalue> is the hex encoded digest. In addition to the above, the following constraints are placed on the API: All URLs which respond with an HTML5 page MUST end with a / and the repository SHOULD redirect the URLs without a / to add a / to the end. URLs may be either absolute or relative as long as th...
...hash() won't become an attribute since attributes should be cheap to compute, which isn't necessarily the case for a hash. Thread: "hash as attribute/property", https://mail.python.org/pipermail/python-3000/2006-April/000362.html Standard types Iterating over a dictionary will continue to yield the keys. Thread: "Iterating over a dict", https://mail.python.org/pipermail/python-3000/2006-April/000283.html Thread: have iter(mapping) generate (key, value) pairs https://mail.python.org/piper...