Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
PythonIniOS/Python-iOS/libPython/Include/dictobject.h at master · SuPair/PythonIniOS · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
View all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
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 }}
SuPair
/
PythonIniOS
Public
forked from
koalahl/PythonIniOS
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Files
Expand file tree
master
Breadcrumbs
PythonIniOS
/
Python-iOS
/
libPython
/
Include
/
dictobject.h
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
executable file
·
156 lines (135 loc) · 6.47 KB
master
Breadcrumbs
PythonIniOS
/
Python-iOS
/
libPython
/
Include
/
dictobject.h
Copy path
Top
File metadata and controls
Code
Blame
executable file
·
156 lines (135 loc) · 6.47 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#ifndef
Py_DICTOBJECT_H
#define
Py_DICTOBJECT_H
#ifdef
__cplusplus
extern
"C"
{
#endif
/* Dictionary object type -- mapping from hashable object to object */
/* The distribution includes a separate file, Objects/dictnotes.txt,
describing explorations into dictionary design and optimization.
It covers typical dictionary use patterns, the parameters for
tuning dictionaries, and several ideas for possible optimizations.
*/
/*
There are three kinds of slots in the table:
1. Unused. me_key == me_value == NULL
Does not hold an active (key, value) pair now and never did. Unused can
transition to Active upon key insertion. This is the only case in which
me_key is NULL, and is each slot's initial state.
2. Active. me_key != NULL and me_key != dummy and me_value != NULL
Holds an active (key, value) pair. Active can transition to Dummy upon
key deletion. This is the only case in which me_value != NULL.
3. Dummy. me_key == dummy and me_value == NULL
Previously held an active (key, value) pair, but that was deleted and an
active pair has not yet overwritten the slot. Dummy can transition to
Active upon key insertion. Dummy slots cannot be made Unused again
(cannot have me_key set to NULL), else the probe sequence in case of
collision would have no way to know they were once active.
Note: .popitem() abuses the me_hash field of an Unused or Dummy slot to
hold a search finger. The me_hash field of Unused or Dummy slots has no
meaning otherwise.
*/
/* PyDict_MINSIZE is the minimum size of a dictionary. This many slots are
* allocated directly in the dict object (in the ma_smalltable member).
* It must be a power of 2, and at least 4. 8 allows dicts with no more
* than 5 active entries to live in ma_smalltable (and so avoid an
* additional malloc); instrumentation suggested this suffices for the
* majority of dicts (consisting mostly of usually-small instance dicts and
* usually-small dicts created to pass keyword arguments).
*/
#define
PyDict_MINSIZE
8
typedef
struct
{
/* Cached hash code of me_key. Note that hash codes are C longs.
* We have to use Py_ssize_t instead because dict_popitem() abuses
* me_hash to hold a search finger.
*/
Py_ssize_t
me_hash
;
PyObject
*
me_key
;
PyObject
*
me_value
;
}
PyDictEntry
;
/*
To ensure the lookup algorithm terminates, there must be at least one Unused
slot (NULL key) in the table.
The value ma_fill is the number of non-NULL keys (sum of Active and Dummy);
ma_used is the number of non-NULL, non-dummy keys (== the number of non-NULL
values == the number of Active items).
To avoid slowing down lookups on a near-full table, we resize the table when
it's two-thirds full.
*/
typedef
struct
_dictobject
PyDictObject
;
struct
_dictobject
{
PyObject_HEAD
Py_ssize_t
ma_fill
;
/* # Active + # Dummy */
Py_ssize_t
ma_used
;
/* # Active */
/* The table contains ma_mask + 1 slots, and that's a power of 2.
* We store the mask instead of the size because the mask is more
* frequently needed.
*/
Py_ssize_t
ma_mask
;
/* ma_table points to ma_smalltable for small tables, else to
* additional malloc'ed memory. ma_table is never NULL! This rule
* saves repeated runtime null-tests in the workhorse getitem and
* setitem calls.
*/
PyDictEntry
*
ma_table
;
PyDictEntry
*
(
*
ma_lookup
)(
PyDictObject
*
mp
,
PyObject
*
key
,
long
hash
);
PyDictEntry
ma_smalltable
[
PyDict_MINSIZE
];
};
PyAPI_DATA
(
PyTypeObject
)
PyDict_Type
;
PyAPI_DATA
(
PyTypeObject
)
PyDictIterKey_Type
;
PyAPI_DATA
(
PyTypeObject
)
PyDictIterValue_Type
;
PyAPI_DATA
(
PyTypeObject
)
PyDictIterItem_Type
;
PyAPI_DATA
(
PyTypeObject
)
PyDictKeys_Type
;
PyAPI_DATA
(
PyTypeObject
)
PyDictItems_Type
;
PyAPI_DATA
(
PyTypeObject
)
PyDictValues_Type
;
#define
PyDict_Check
(
op
) \
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_DICT_SUBCLASS)
#define
PyDict_CheckExact
(
op
) (Py_TYPE(op) == &PyDict_Type)
#define
PyDictKeys_Check
(
op
) (Py_TYPE(op) == &PyDictKeys_Type)
#define
PyDictItems_Check
(
op
) (Py_TYPE(op) == &PyDictItems_Type)
#define
PyDictValues_Check
(
op
) (Py_TYPE(op) == &PyDictValues_Type)
/* This excludes Values, since they are not sets. */
# define
PyDictViewSet_Check
(
op
) \
(PyDictKeys_Check(op) || PyDictItems_Check(op))
PyAPI_FUNC
(
PyObject
*
)
PyDict_New
(
void
);
PyAPI_FUNC
(
PyObject
*
)
PyDict_GetItem
(
PyObject
*
mp
,
PyObject
*
key
);
PyAPI_FUNC
(
int
)
PyDict_SetItem
(
PyObject
*
mp
,
PyObject
*
key
,
PyObject
*
item
);
PyAPI_FUNC
(
int
)
PyDict_DelItem
(
PyObject
*
mp
,
PyObject
*
key
);
PyAPI_FUNC
(
void
)
PyDict_Clear
(
PyObject
*
mp
);
PyAPI_FUNC
(
int
)
PyDict_Next
(
PyObject
*
mp
,
Py_ssize_t
*
pos
,
PyObject
*
*
key
,
PyObject
*
*
value
);
PyAPI_FUNC
(
int
)
_PyDict_Next
(
PyObject
*
mp
,
Py_ssize_t
*
pos
,
PyObject
*
*
key
,
PyObject
*
*
value
,
long
*
hash
);
PyAPI_FUNC
(
PyObject
*
)
PyDict_Keys
(
PyObject
*
mp
);
PyAPI_FUNC
(
PyObject
*
)
PyDict_Values
(
PyObject
*
mp
);
PyAPI_FUNC
(
PyObject
*
)
PyDict_Items
(
PyObject
*
mp
);
PyAPI_FUNC
(
Py_ssize_t
)
PyDict_Size
(
PyObject
*
mp
);
PyAPI_FUNC
(
PyObject
*
)
PyDict_Copy
(
PyObject
*
mp
);
PyAPI_FUNC
(
int
)
PyDict_Contains
(
PyObject
*
mp
,
PyObject
*
key
);
PyAPI_FUNC
(
int
)
_PyDict_Contains
(
PyObject
*
mp
,
PyObject
*
key
,
long
hash
);
PyAPI_FUNC
(
PyObject
*
)
_PyDict_NewPresized
(
Py_ssize_t
minused
);
PyAPI_FUNC
(
void
)
_PyDict_MaybeUntrack
(
PyObject
*
mp
);
/* PyDict_Update(mp, other) is equivalent to PyDict_Merge(mp, other, 1). */
PyAPI_FUNC
(
int
)
PyDict_Update
(
PyObject
*
mp
,
PyObject
*
other
);
/* PyDict_Merge updates/merges from a mapping object (an object that
supports PyMapping_Keys() and PyObject_GetItem()). If override is true,
the last occurrence of a key wins, else the first. The Python
dict.update(other) is equivalent to PyDict_Merge(dict, other, 1).
*/
PyAPI_FUNC
(
int
)
PyDict_Merge
(
PyObject
*
mp
,
PyObject
*
other
,
int
override
);
/* PyDict_MergeFromSeq2 updates/merges from an iterable object producing
iterable objects of length 2. If override is true, the last occurrence
of a key wins, else the first. The Python dict constructor dict(seq2)
is equivalent to dict={}; PyDict_MergeFromSeq(dict, seq2, 1).
*/
PyAPI_FUNC
(
int
)
PyDict_MergeFromSeq2
(
PyObject
*
d
,
PyObject
*
seq2
,
int
override
);
PyAPI_FUNC
(
PyObject
*
)
PyDict_GetItemString
(
PyObject
*
dp
,
const
char
*
key
);
PyAPI_FUNC
(
int
)
PyDict_SetItemString
(
PyObject
*
dp
,
const
char
*
key
,
PyObject
*
item
);
PyAPI_FUNC
(
int
)
PyDict_DelItemString
(
PyObject
*
dp
,
const
char
*
key
);
#ifdef
__cplusplus
}
#endif
#endif
/* !Py_DICTOBJECT_H */
You can’t perform that action at this time.