Skip to content

Commit

Permalink
edgedb.NamedTuple is now a subclass of tuple
Browse files Browse the repository at this point in the history
edgedb.NamedTuple will now create a heap type for the names.
weakref.ref() will stop working on edgedb.NamedTuple objects.
  • Loading branch information
fantix committed Sep 20, 2022
1 parent e694570 commit bb3b8e7
Show file tree
Hide file tree
Showing 7 changed files with 143 additions and 156 deletions.
11 changes: 1 addition & 10 deletions edgedb/datatypes/datatypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,9 @@ PyObject * EdgeRecordDesc_GetDataclassFields(PyObject *);

extern PyTypeObject EdgeNamedTuple_Type;

#define EdgeNamedTuple_Check(d) (Py_TYPE(d) == &EdgeNamedTuple_Type)

typedef struct {
PyObject_VAR_HEAD
PyObject *desc;
PyObject *weakreflist;
PyObject *ob_item[1];
} EdgeNamedTupleObject;

PyObject * EdgeNamedTuple_InitType(void);
PyObject * EdgeNamedTuple_Type_New(PyObject *);
PyObject * EdgeNamedTuple_New(PyObject *);
int EdgeNamedTuple_SetItem(PyObject *, Py_ssize_t, PyObject *);


/* === edgedb.Object ======================================== */
Expand Down
4 changes: 2 additions & 2 deletions edgedb/datatypes/datatypes.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ cdef extern from "datatypes.h":

object EdgeNamedTuple_InitType()
object EdgeNamedTuple_New(object)
int EdgeNamedTuple_SetItem(object, Py_ssize_t, object) except -1
object EdgeNamedTuple_Type_New(object)

object EdgeObject_InitType()
object EdgeObject_New(object);
Expand All @@ -75,7 +75,7 @@ cdef record_desc_new(object names, object flags, object cards)
cdef record_desc_pointer_name(object desc, Py_ssize_t pos)
cdef record_desc_pointer_card(object desc, Py_ssize_t pos)
cdef namedtuple_new(object desc)
cdef namedtuple_set(object tuple, Py_ssize_t pos, object elem)
cdef namedtuple_type_new(object desc)
cdef object_new(object desc)
cdef object_set(object tuple, Py_ssize_t pos, object elem)
cdef bint set_check(object set)
Expand Down
4 changes: 2 additions & 2 deletions edgedb/datatypes/datatypes.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ cdef namedtuple_new(object desc):
return EdgeNamedTuple_New(desc)


cdef namedtuple_set(object tuple, Py_ssize_t pos, object elem):
EdgeNamedTuple_SetItem(tuple, pos, elem)
cdef namedtuple_type_new(object desc):
return EdgeNamedTuple_Type_New(desc)


cdef object_new(object desc):
Expand Down
3 changes: 1 addition & 2 deletions edgedb/datatypes/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@


#define _Edge_IsContainer(o) \
(PyTuple_CheckExact(o) || \
EdgeNamedTuple_Check(o) || \
(PyTuple_Check(o) || \
EdgeObject_Check(o) || \
EdgeSet_Check(o) || \
EdgeArray_Check(o))
Expand Down
Loading

0 comments on commit bb3b8e7

Please sign in to comment.