[ Web Proxy ]
URL:
Viewing:
https://github-redirect.dependabot.com/python/cpython/blob/main/Include/pyhash.h
[Back]
[Original]
cpython/Include/pyhash.h at main python/cpython GitHub
Skip to content
Navigation Menu
Sign in
Products
Platform
[]
[]
GitHub
Repository hosting, code review, and collaboration
[]
[]
Copilot
AI coding agent for tasks, projects and automated work
Build & Ship
Actions
CI/CD and automation
Code Quality
Quality analysis, fixes, and enforcement
Codespaces
Cloud development environments
Secure
Code Security
Vulnerability detection and remediation
Secret Protection
Secret scanning and leak prevention
All Features
Developers
Learn
Documentation
Training
Certifications
Build
Build with Copilot
Customize Copilot
Integrations
Explore
Trending repos
GitHub Sponsors
Events
Changelog
[]
[]
Changelog
Your source for the latest features, improvements, and fixes across GitHub products, all in one place.
Businesses
By Stage
Enterprises
Team
Startups
Nonprofits
By Industry
Healthcare
Financial services
Manufacturing
Government
See all industries
Evaluate GitHub
Why GitHub
Customer Stories
Business insights
Trust Center
Add-ons
GitHub Advanced Security
Enterprise-grade code security
Copilot for business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Resources
Learn & Connect
Documentation
Resource center
Blog
Events & webinars
Community Forum
Customer Stories
Integrations
Support
Customer support
Training
GitHub Status
Company
About
Partners
Changelog
GitHub Universe
[]
[]
GitHub Universe
The event for developers, by developers talks, workshops, and whats next for GitHub.
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
python
cpython
Repository navigation
Code
Issues
5k+
(5k+)
Pull requests
2.3k
(2.3k)
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
main
Breadcrumbs
cpython
/
Include
/
pyhash.h
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
63 lines (56 loc) 1.77 KB
main
Breadcrumbs
cpython
/
Include
/
pyhash.h
Copy path
Top
File metadata and controls
Code
Blame
63 lines (56 loc) 1.77 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifndef
Py_HASH_H
#define
Py_HASH_H
#ifdef
__cplusplus
extern
"C"
{
#endif
/* Cutoff for small string DJBX33A optimization in range [1, cutoff).
*
* About 50% of the strings in a typical Python application are smaller than
* 6 to 7 chars. However DJBX33A is vulnerable to hash collision attacks.
* NEVER use DJBX33A for long strings!
*
* A Py_HASH_CUTOFF of 0 disables small string optimization. 32 bit platforms
* should use a smaller cutoff because it is easier to create colliding
* strings. A cutoff of 7 on 64bit platforms and 5 on 32bit platforms should
* provide a decent safety margin.
*/
#ifndef
Py_HASH_CUTOFF
# define
Py_HASH_CUTOFF
0
#elif
(
Py_HASH_CUTOFF
>
7
||
Py_HASH_CUTOFF
<
0
)
# error
Py_HASH_CUTOFF must in range 0...7.
#endif
/* Py_HASH_CUTOFF */
/* Hash algorithm selection
*
* The values for Py_HASH_* are hard-coded in the
* configure script.
*
* - FNV and SIPHASH* are available on all platforms and architectures.
* - With EXTERNAL embedders can provide an alternative implementation with::
*
* PyHash_FuncDef PyHash_Func = {...};
*
* XXX: Figure out __declspec() for extern PyHash_FuncDef.
*/
#define
Py_HASH_EXTERNAL
0
#define
Py_HASH_SIPHASH24
1
#define
Py_HASH_FNV
2
#define
Py_HASH_SIPHASH13
3
#ifndef
Py_HASH_ALGORITHM
# ifndef
HAVE_ALIGNED_REQUIRED
# define
Py_HASH_ALGORITHM
Py_HASH_SIPHASH13
# else
# define
Py_HASH_ALGORITHM
Py_HASH_FNV
# endif
/* uint64_t && uint32_t && aligned */
#endif
/* Py_HASH_ALGORITHM */
#if
!defined(
Py_LIMITED_API
)
||
Py_LIMITED_API
+
0
>=
_Py_PACK_VERSION
(
3
,
16
)
PyAPI_FUNC
(
Py_hash_t
)
Py_HashBuffer
(
const
void
*
ptr
,
Py_ssize_t
len
);
#endif
#ifndef
Py_LIMITED_API
# define
Py_CPYTHON_HASH_H
# include
"cpython/pyhash.h"
# undef
Py_CPYTHON_HASH_H
#endif
#ifdef
__cplusplus
}
#endif
#endif
// !Py_HASH_H
Footer
© 2026 GitHub, Inc.
Footer navigation
Terms
Privacy
Security
Status
Community
Docs
Contact
Manage cookies
Do not share my personal information
You cant perform that action at this time.
Web Proxy Viewer |
New URL
|
Original Page