Coverage Report

Created: 2025-11-11 07:03

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/cpython3/Include/cpython/setobject.h
Line
Count
Source
1
#ifndef Py_CPYTHON_SETOBJECT_H
2
#  error "this header file must not be included directly"
3
#endif
4
5
/* There are three kinds of entries in the table:
6
7
1. Unused:  key == NULL and hash == 0
8
2. Dummy:   key == dummy and hash == -1
9
3. Active:  key != NULL and key != dummy and hash != -1
10
11
The hash field of Unused slots is always zero.
12
13
The hash field of Dummy slots are set to -1
14
meaning that dummy entries can be detected by
15
either entry->key==dummy or by entry->hash==-1.
16
*/
17
18
826k
#define PySet_MINSIZE 8
19
20
typedef struct {
21
    PyObject *key;
22
    Py_hash_t hash;             /* Cached hash code of the key */
23
} setentry;
24
25
/* The SetObject data structure is shared by set and frozenset objects.
26
27
Invariant for sets:
28
 - hash is -1
29
30
Invariants for frozensets:
31
 - data is immutable.
32
 - hash is the hash of the frozenset or -1 if not computed yet.
33
34
*/
35
36
typedef struct {
37
    PyObject_HEAD
38
39
    Py_ssize_t fill;            /* Number active and dummy entries*/
40
    Py_ssize_t used;            /* Number active entries */
41
42
    /* The table contains mask + 1 slots, and that's a power of 2.
43
     * We store the mask instead of the size because the mask is more
44
     * frequently needed.
45
     */
46
    Py_ssize_t mask;
47
48
    /* The table points to a fixed-size smalltable for small tables
49
     * or to additional malloc'ed memory for bigger tables.
50
     * The table pointer is never NULL which saves us from repeated
51
     * runtime null-tests.
52
     */
53
    setentry *table;
54
    Py_hash_t hash;             /* Only used by frozenset objects */
55
    Py_ssize_t finger;          /* Search finger for pop() */
56
57
    setentry smalltable[PySet_MINSIZE];
58
    PyObject *weakreflist;      /* List of weak references */
59
} PySetObject;
60
61
#define _PySet_CAST(so) \
62
2.48M
    (assert(PyAnySet_Check(so)), _Py_CAST(PySetObject*, so))
63
64
123k
static inline Py_ssize_t PySet_GET_SIZE(PyObject *so) {
65
#ifdef Py_GIL_DISABLED
66
    return _Py_atomic_load_ssize_relaxed(&(_PySet_CAST(so)->used));
67
#else
68
123k
    return _PySet_CAST(so)->used;
69
123k
#endif
70
123k
}
Unexecuted instantiation: exceptions.c:PySet_GET_SIZE
Unexecuted instantiation: genericaliasobject.c:PySet_GET_SIZE
listobject.c:PySet_GET_SIZE
Line
Count
Source
64
41.3k
static inline Py_ssize_t PySet_GET_SIZE(PyObject *so) {
65
#ifdef Py_GIL_DISABLED
66
    return _Py_atomic_load_ssize_relaxed(&(_PySet_CAST(so)->used));
67
#else
68
41.3k
    return _PySet_CAST(so)->used;
69
41.3k
#endif
70
41.3k
}
Unexecuted instantiation: longobject.c:PySet_GET_SIZE
Unexecuted instantiation: dictobject.c:PySet_GET_SIZE
Unexecuted instantiation: moduleobject.c:PySet_GET_SIZE
Unexecuted instantiation: object.c:PySet_GET_SIZE
Unexecuted instantiation: obmalloc.c:PySet_GET_SIZE
Unexecuted instantiation: picklebufobject.c:PySet_GET_SIZE
Unexecuted instantiation: rangeobject.c:PySet_GET_SIZE
setobject.c:PySet_GET_SIZE
Line
Count
Source
64
75.4k
static inline Py_ssize_t PySet_GET_SIZE(PyObject *so) {
65
#ifdef Py_GIL_DISABLED
66
    return _Py_atomic_load_ssize_relaxed(&(_PySet_CAST(so)->used));
67
#else
68
75.4k
    return _PySet_CAST(so)->used;
69
75.4k
#endif
70
75.4k
}
Unexecuted instantiation: sliceobject.c:PySet_GET_SIZE
Unexecuted instantiation: structseq.c:PySet_GET_SIZE
Unexecuted instantiation: templateobject.c:PySet_GET_SIZE
Unexecuted instantiation: tupleobject.c:PySet_GET_SIZE
Unexecuted instantiation: typeobject.c:PySet_GET_SIZE
Unexecuted instantiation: typevarobject.c:PySet_GET_SIZE
Unexecuted instantiation: unicode_formatter.c:PySet_GET_SIZE
Unexecuted instantiation: unicode_writer.c:PySet_GET_SIZE
Unexecuted instantiation: unicodectype.c:PySet_GET_SIZE
Unexecuted instantiation: unicodeobject.c:PySet_GET_SIZE
Unexecuted instantiation: unionobject.c:PySet_GET_SIZE
Unexecuted instantiation: weakrefobject.c:PySet_GET_SIZE
Unexecuted instantiation: _warnings.c:PySet_GET_SIZE
Unexecuted instantiation: bltinmodule.c:PySet_GET_SIZE
Unexecuted instantiation: ceval.c:PySet_GET_SIZE
Unexecuted instantiation: codecs.c:PySet_GET_SIZE
Unexecuted instantiation: codegen.c:PySet_GET_SIZE
Unexecuted instantiation: compile.c:PySet_GET_SIZE
Unexecuted instantiation: context.c:PySet_GET_SIZE
Unexecuted instantiation: errors.c:PySet_GET_SIZE
Unexecuted instantiation: flowgraph.c:PySet_GET_SIZE
Unexecuted instantiation: frame.c:PySet_GET_SIZE
Unexecuted instantiation: future.c:PySet_GET_SIZE
Unexecuted instantiation: gc.c:PySet_GET_SIZE
Unexecuted instantiation: gc_gil.c:PySet_GET_SIZE
Unexecuted instantiation: getargs.c:PySet_GET_SIZE
Unexecuted instantiation: ceval_gil.c:PySet_GET_SIZE
Unexecuted instantiation: hamt.c:PySet_GET_SIZE
Unexecuted instantiation: hashtable.c:PySet_GET_SIZE
Unexecuted instantiation: import.c:PySet_GET_SIZE
Unexecuted instantiation: importdl.c:PySet_GET_SIZE
Unexecuted instantiation: initconfig.c:PySet_GET_SIZE
Unexecuted instantiation: instrumentation.c:PySet_GET_SIZE
Unexecuted instantiation: instruction_sequence.c:PySet_GET_SIZE
Unexecuted instantiation: intrinsics.c:PySet_GET_SIZE
Unexecuted instantiation: legacy_tracing.c:PySet_GET_SIZE
Unexecuted instantiation: lock.c:PySet_GET_SIZE
Unexecuted instantiation: marshal.c:PySet_GET_SIZE
Unexecuted instantiation: modsupport.c:PySet_GET_SIZE
Unexecuted instantiation: mysnprintf.c:PySet_GET_SIZE
Unexecuted instantiation: parking_lot.c:PySet_GET_SIZE
Unexecuted instantiation: preconfig.c:PySet_GET_SIZE
Unexecuted instantiation: pyarena.c:PySet_GET_SIZE
Unexecuted instantiation: pyctype.c:PySet_GET_SIZE
Unexecuted instantiation: pyhash.c:PySet_GET_SIZE
Unexecuted instantiation: pylifecycle.c:PySet_GET_SIZE
Unexecuted instantiation: pystate.c:PySet_GET_SIZE
Unexecuted instantiation: pythonrun.c:PySet_GET_SIZE
Unexecuted instantiation: pytime.c:PySet_GET_SIZE
Unexecuted instantiation: qsbr.c:PySet_GET_SIZE
Unexecuted instantiation: bootstrap_hash.c:PySet_GET_SIZE
Unexecuted instantiation: specialize.c:PySet_GET_SIZE
Unexecuted instantiation: symtable.c:PySet_GET_SIZE
Unexecuted instantiation: sysmodule.c:PySet_GET_SIZE
Unexecuted instantiation: thread.c:PySet_GET_SIZE
Unexecuted instantiation: traceback.c:PySet_GET_SIZE
Unexecuted instantiation: tracemalloc.c:PySet_GET_SIZE
Unexecuted instantiation: getopt.c:PySet_GET_SIZE
Unexecuted instantiation: pystrcmp.c:PySet_GET_SIZE
Unexecuted instantiation: pystrtod.c:PySet_GET_SIZE
Unexecuted instantiation: dtoa.c:PySet_GET_SIZE
Unexecuted instantiation: fileutils.c:PySet_GET_SIZE
Unexecuted instantiation: suggestions.c:PySet_GET_SIZE
Unexecuted instantiation: perf_trampoline.c:PySet_GET_SIZE
Unexecuted instantiation: perf_jit_trampoline.c:PySet_GET_SIZE
Unexecuted instantiation: remote_debugging.c:PySet_GET_SIZE
Unexecuted instantiation: dynload_shlib.c:PySet_GET_SIZE
Unexecuted instantiation: config.c:PySet_GET_SIZE
Unexecuted instantiation: gcmodule.c:PySet_GET_SIZE
Unexecuted instantiation: _asynciomodule.c:PySet_GET_SIZE
Unexecuted instantiation: atexitmodule.c:PySet_GET_SIZE
Unexecuted instantiation: faulthandler.c:PySet_GET_SIZE
Unexecuted instantiation: posixmodule.c:PySet_GET_SIZE
Unexecuted instantiation: signalmodule.c:PySet_GET_SIZE
Unexecuted instantiation: _tracemalloc.c:PySet_GET_SIZE
Unexecuted instantiation: _suggestions.c:PySet_GET_SIZE
Unexecuted instantiation: _datetimemodule.c:PySet_GET_SIZE
Unexecuted instantiation: _codecsmodule.c:PySet_GET_SIZE
Unexecuted instantiation: _collectionsmodule.c:PySet_GET_SIZE
Unexecuted instantiation: _iomodule.c:PySet_GET_SIZE
Unexecuted instantiation: iobase.c:PySet_GET_SIZE
Unexecuted instantiation: fileio.c:PySet_GET_SIZE
Unexecuted instantiation: bytesio.c:PySet_GET_SIZE
Unexecuted instantiation: bufferedio.c:PySet_GET_SIZE
Unexecuted instantiation: textio.c:PySet_GET_SIZE
Unexecuted instantiation: stringio.c:PySet_GET_SIZE
Unexecuted instantiation: itertoolsmodule.c:PySet_GET_SIZE
Unexecuted instantiation: sre.c:PySet_GET_SIZE
Unexecuted instantiation: _sysconfig.c:PySet_GET_SIZE
Unexecuted instantiation: _threadmodule.c:PySet_GET_SIZE
Unexecuted instantiation: timemodule.c:PySet_GET_SIZE
Unexecuted instantiation: _typesmodule.c:PySet_GET_SIZE
Unexecuted instantiation: _typingmodule.c:PySet_GET_SIZE
Unexecuted instantiation: _weakref.c:PySet_GET_SIZE
_abc.c:PySet_GET_SIZE
Line
Count
Source
64
471
static inline Py_ssize_t PySet_GET_SIZE(PyObject *so) {
65
#ifdef Py_GIL_DISABLED
66
    return _Py_atomic_load_ssize_relaxed(&(_PySet_CAST(so)->used));
67
#else
68
471
    return _PySet_CAST(so)->used;
69
471
#endif
70
471
}
Unexecuted instantiation: _functoolsmodule.c:PySet_GET_SIZE
Unexecuted instantiation: _localemodule.c:PySet_GET_SIZE
Unexecuted instantiation: _opcode.c:PySet_GET_SIZE
Unexecuted instantiation: _operator.c:PySet_GET_SIZE
Unexecuted instantiation: symtablemodule.c:PySet_GET_SIZE
Unexecuted instantiation: pwdmodule.c:PySet_GET_SIZE
Unexecuted instantiation: getpath.c:PySet_GET_SIZE
Unexecuted instantiation: frozen.c:PySet_GET_SIZE
Unexecuted instantiation: getbuildinfo.c:PySet_GET_SIZE
Unexecuted instantiation: peg_api.c:PySet_GET_SIZE
Unexecuted instantiation: file_tokenizer.c:PySet_GET_SIZE
Unexecuted instantiation: helpers.c:PySet_GET_SIZE
Unexecuted instantiation: myreadline.c:PySet_GET_SIZE
Unexecuted instantiation: abstract.c:PySet_GET_SIZE
Unexecuted instantiation: boolobject.c:PySet_GET_SIZE
Unexecuted instantiation: bytes_methods.c:PySet_GET_SIZE
Unexecuted instantiation: bytearrayobject.c:PySet_GET_SIZE
Unexecuted instantiation: bytesobject.c:PySet_GET_SIZE
Unexecuted instantiation: call.c:PySet_GET_SIZE
Unexecuted instantiation: capsule.c:PySet_GET_SIZE
Unexecuted instantiation: cellobject.c:PySet_GET_SIZE
Unexecuted instantiation: classobject.c:PySet_GET_SIZE
codeobject.c:PySet_GET_SIZE
Line
Count
Source
64
6.26k
static inline Py_ssize_t PySet_GET_SIZE(PyObject *so) {
65
#ifdef Py_GIL_DISABLED
66
    return _Py_atomic_load_ssize_relaxed(&(_PySet_CAST(so)->used));
67
#else
68
6.26k
    return _PySet_CAST(so)->used;
69
6.26k
#endif
70
6.26k
}
Unexecuted instantiation: complexobject.c:PySet_GET_SIZE
Unexecuted instantiation: descrobject.c:PySet_GET_SIZE
Unexecuted instantiation: enumobject.c:PySet_GET_SIZE
Unexecuted instantiation: genobject.c:PySet_GET_SIZE
Unexecuted instantiation: fileobject.c:PySet_GET_SIZE
Unexecuted instantiation: floatobject.c:PySet_GET_SIZE
Unexecuted instantiation: frameobject.c:PySet_GET_SIZE
Unexecuted instantiation: funcobject.c:PySet_GET_SIZE
Unexecuted instantiation: interpolationobject.c:PySet_GET_SIZE
Unexecuted instantiation: iterobject.c:PySet_GET_SIZE
Unexecuted instantiation: odictobject.c:PySet_GET_SIZE
Unexecuted instantiation: memoryobject.c:PySet_GET_SIZE
Unexecuted instantiation: methodobject.c:PySet_GET_SIZE
Unexecuted instantiation: namespaceobject.c:PySet_GET_SIZE
Unexecuted instantiation: unicode_format.c:PySet_GET_SIZE
Unexecuted instantiation: _contextvars.c:PySet_GET_SIZE
Unexecuted instantiation: Python-ast.c:PySet_GET_SIZE
Unexecuted instantiation: Python-tokenize.c:PySet_GET_SIZE
Unexecuted instantiation: asdl.c:PySet_GET_SIZE
Unexecuted instantiation: assemble.c:PySet_GET_SIZE
Unexecuted instantiation: ast.c:PySet_GET_SIZE
Unexecuted instantiation: ast_preprocess.c:PySet_GET_SIZE
Unexecuted instantiation: ast_unparse.c:PySet_GET_SIZE
Unexecuted instantiation: critical_section.c:PySet_GET_SIZE
Unexecuted instantiation: crossinterp.c:PySet_GET_SIZE
Unexecuted instantiation: getcopyright.c:PySet_GET_SIZE
Unexecuted instantiation: getplatform.c:PySet_GET_SIZE
Unexecuted instantiation: getversion.c:PySet_GET_SIZE
Unexecuted instantiation: optimizer.c:PySet_GET_SIZE
Unexecuted instantiation: pathconfig.c:PySet_GET_SIZE
Unexecuted instantiation: pymath.c:PySet_GET_SIZE
Unexecuted instantiation: structmember.c:PySet_GET_SIZE
Unexecuted instantiation: pystrhex.c:PySet_GET_SIZE
Unexecuted instantiation: pegen.c:PySet_GET_SIZE
Unexecuted instantiation: pegen_errors.c:PySet_GET_SIZE
Unexecuted instantiation: parser.c:PySet_GET_SIZE
Unexecuted instantiation: buffer.c:PySet_GET_SIZE
Unexecuted instantiation: lexer.c:PySet_GET_SIZE
Unexecuted instantiation: state.c:PySet_GET_SIZE
Unexecuted instantiation: readline_tokenizer.c:PySet_GET_SIZE
Unexecuted instantiation: string_tokenizer.c:PySet_GET_SIZE
Unexecuted instantiation: utf8_tokenizer.c:PySet_GET_SIZE
Unexecuted instantiation: getcompiler.c:PySet_GET_SIZE
Unexecuted instantiation: mystrtoul.c:PySet_GET_SIZE
Unexecuted instantiation: token.c:PySet_GET_SIZE
Unexecuted instantiation: action_helpers.c:PySet_GET_SIZE
Unexecuted instantiation: string_parser.c:PySet_GET_SIZE
71
123k
#define PySet_GET_SIZE(so) PySet_GET_SIZE(_PyObject_CAST(so))