Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

AddPyUnstable_Unicode_GET_CACHED_HASH #134891

Closed
Assignees
encukou
Labels
@encukou

Description

@encukou

Feature or enhancement

Proposal:

I'd like to add a quick way to maybe get astr hash, so that advanced users don't need to reach into the undocumented-but-publicPyASCIIObject->hash.

Py_hash_tPyUnstable_Unicode_GET_CACHED_HASH(PyObject*str)

If the hash ofstr, as returned byPyObject_Hash, has been cached and is immediately available, return it.
Otherwise, return-1without setting an exception.

Ifstr is not a string (that is, ifPyUnicode_Check(obj) is false), the behavior is undefined.

This function never fails with an exception.

Note that there are no guarantees on when a object's hash is cached, and the (non-)existence of a cached hash does not imply that the string has any other properties.

Has this already been discussed elsewhere?

I have already discussed this feature proposal on Discourse

Links to previous discussion of this feature:

https://discuss.python.org/t/82543

Linked PRs

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp