<commit_before># --------------------------------------------------------------------

cdef extern from "stdio.h" nogil:
    int printf(char *, ...)

cdef extern from "Python.h":
    ctypedef struct PyObject
    ctypedef struct PyTypeObject
    ctypedef int visitproc(PyObject *, void *)
    ctypedef int traverseproc(PyObject *, visitproc, void *)
    ctypedef int inquiry(PyObject *)
    ctypedef struct PyTypeObject:
       char*        tp_name
       traverseproc tp_traverse
       inquiry      tp_clear
    PyTypeObject *Py_TYPE(PyObject *)
    ctypedef struct PyGC_Head:
       Py_ssize_t gc_refs"gc.gc_refs"
    PyGC_Head *_Py_AS_GC(PyObject*)
    enum: _PyGC_REFS_REACHABLE

cdef int tp_traverse(PyObject *o, visitproc visit, void *arg):
    ## printf("%s.tp_traverse(%p)\n", Py_TYPE(o).tp_name, <void*>o)
    cdef PetscObject p = (<Object>o).obj[0]
    if p == NULL: return 0
    cdef PyObject *d = <PyObject*>p.python_context
    if d == NULL: return 0
    if arg == NULL and _Py_AS_GC(d).gc_refs == 0:
        _Py_AS_GC(d).gc_refs = _PyGC_REFS_REACHABLE
    return visit(d, arg)

cdef int tp_clear(PyObject *o):<commit_msg>Yet another attempt to get GC hackery working<commit_after># --------------------------------------------------------------------

cdef extern from "stdio.h" nogil:
    int printf(char *, ...)

cdef extern from "Python.h":
    ctypedef struct PyObject
    ctypedef struct PyTypeObject
    ctypedef int visitproc(PyObject *, void *)
    ctypedef int traverseproc(PyObject *, visitproc, void *)
    ctypedef int inquiry(PyObject *)
    ctypedef struct PyTypeObject:
       char*        tp_name
       traverseproc tp_traverse
       inquiry      tp_clear
    PyTypeObject *Py_TYPE(PyObject *)
    ctypedef struct PyGC_Head:
       Py_ssize_t gc_refs"gc.gc_refs"
    PyGC_Head *_Py_AS_GC(PyObject*)

cdef int tp_traverse(PyObject *o, visitproc visit, void *arg):
    ## printf("%s.tp_traverse(%p)\n", Py_TYPE(o).tp_name, <void*>o)
    cdef PetscObject p = (<Object>o).obj[0]
    if p == NULL: return 0
    cdef PyObject *d = <PyObject*>p.python_context
    if d == NULL: return 0
    if arg == NULL and _Py_AS_GC(d).gc_refs == 0:
        _Py_AS_GC(d).gc_refs = 1
    return visit(d, arg)

cdef int tp_clear(PyObject *o):
{'fraction_non_alphanumeric': 0.16119005328596803, 'fraction_numerical': 0.003996447602131439, 'mean_word_length': 2.564873417721519, 'pattern_counts': {'":': 2, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3357544', 'n_tokens_mistral': 786, 'n_tokens_neox': 767, 'n_words': 192}