PEP 227 implementation

A cell contains a reference to a single PyObject.  It could be
implemented as a mutable, one-element sequence, but the separate type
has less overhead.
This commit is contained in:
Jeremy Hylton 2001-01-25 20:04:14 +00:00
parent c34a5ade0a
commit fbd849f201
4 changed files with 145 additions and 0 deletions

View file

@ -81,6 +81,7 @@
#include "cobject.h"
#include "traceback.h"
#include "sliceobject.h"
#include "cellobject.h"
#include "codecs.h"
#include "pyerrors.h"

28
Include/cellobject.h Normal file
View file

@ -0,0 +1,28 @@
/* Cell object interface */
#ifndef Py_CELLOBJECT_H
#define Py_CELLOBJECT_H
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
PyObject_VAR_HEAD
PyObject *ob_ref;
} PyCellObject;
extern DL_IMPORT(PyTypeObject) PyCell_Type;
#define PyCell_Check(op) ((op)->ob_type == &PyCell_Type)
extern DL_IMPORT(PyObject *) PyCell_New(PyObject *);
extern DL_IMPORT(PyObject *) PyCell_Get(PyObject *);
extern DL_IMPORT(int) PyCell_Set(PyObject *, PyObject *);
#define PyCell_GET(op) (((PyCellObject *)(op))->ob_ref)
#define PyCell_SET(op, v) (((PyCellObject *)(op))->ob_ref = v)
#ifdef __cplusplus
}
#endif
#endif /* !Py_TUPLEOBJECT_H */