forked from bloomberg/pystack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdict.h
More file actions
102 lines (85 loc) · 2.1 KB
/
dict.h
File metadata and controls
102 lines (85 loc) · 2.1 KB
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
#pragma once
#include "object.h"
#include "string.h"
namespace pystack {
namespace Python2 {
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;
typedef struct _dictobject
{
PyObject_HEAD Py_ssize_t ma_fill;
Py_ssize_t ma_used;
Py_ssize_t ma_mask;
PyDictEntry* ma_table;
} PyDictObject;
} // namespace Python2
namespace Python3 {
typedef Py_ssize_t (*dict_lookup_func)(void* mp, PyObject* key, Py_hash_t hash, PyObject** value_addr);
struct PyDictKeysObject;
typedef struct
{
Py_hash_t me_hash;
PyObject* me_key;
PyObject* me_value;
} PyDictKeyEntry;
/* See dictobject.c for actual layout of DictKeysObject */
typedef struct
{
PyObject_HEAD Py_ssize_t ma_used;
uint64_t ma_version_tag;
PyDictKeysObject* ma_keys;
PyObject** ma_values;
} PyDictObject;
typedef struct _dictvalues
{
PyObject* values[1];
} PyDictValuesObject;
} // namespace Python3
namespace Python3_3 {
typedef struct _dictkeysobject
{
Py_ssize_t dk_refcnt;
Py_ssize_t dk_size;
Python3::dict_lookup_func dk_lookup;
Py_ssize_t dk_usable;
Py_ssize_t dk_nentries;
char dk_indices[]; /* char is required to avoid strict aliasing. */
} PyDictKeysObject;
} // namespace Python3_3
namespace Python3_11 {
typedef struct
{
PyObject* me_key;
PyObject* me_value;
} PyDictUnicodeEntry;
typedef struct _dictkeysobject
{
Py_ssize_t dk_refcnt;
uint8_t dk_log2_size;
uint8_t dk_log2_index_bytes;
uint8_t dk_kind;
uint32_t dk_version;
Py_ssize_t dk_usable;
Py_ssize_t dk_nentries;
char dk_indices[1]; /* char is required to avoid strict aliasing. */
} PyDictKeysObject;
} // namespace Python3_11
namespace Python3_13 {
typedef struct _dictvalues
{
uint8_t capacity;
uint8_t size;
uint8_t embedded;
uint8_t valid;
PyObject* values[1];
} PyDictValuesObject;
} // namespace Python3_13
} // namespace pystack