home *** CD-ROM | disk | FTP | other *** search
/ linuxmafia.com 2016 / linuxmafia.com.tar / linuxmafia.com / pub / palmos / pippy-0.6beta-src.tar.gz / pippy-0.6beta-src.tar / pippy-0.6beta-src / src / Include / object.h < prev    next >
C/C++ Source or Header  |  2000-12-21  |  19KB  |  521 lines

  1. #ifndef Py_OBJECT_H
  2. #define Py_OBJECT_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6.  
  7. /***********************************************************
  8. Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
  9. The Netherlands.
  10.  
  11.                         All Rights Reserved
  12.  
  13. Permission to use, copy, modify, and distribute this software and its
  14. documentation for any purpose and without fee is hereby granted,
  15. provided that the above copyright notice appear in all copies and that
  16. both that copyright notice and this permission notice appear in
  17. supporting documentation, and that the names of Stichting Mathematisch
  18. Centrum or CWI or Corporation for National Research Initiatives or
  19. CNRI not be used in advertising or publicity pertaining to
  20. distribution of the software without specific, written prior
  21. permission.
  22.  
  23. While CWI is the initial source for this software, a modified version
  24. is made available by the Corporation for National Research Initiatives
  25. (CNRI) at the Internet address ftp://ftp.python.org.
  26.  
  27. STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
  28. REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
  29. MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH
  30. CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
  31. DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  32. PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  33. TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  34. PERFORMANCE OF THIS SOFTWARE.
  35.  
  36. ******************************************************************/
  37.  
  38. /* Object and type object interface */
  39.  
  40. /*
  41. Objects are structures allocated on the heap.  Special rules apply to
  42. the use of objects to ensure they are properly garbage-collected.
  43. Objects are never allocated statically or on the stack; they must be
  44. accessed through special macros and functions only.  (Type objects are
  45. exceptions to the first rule; the standard types are represented by
  46. statically initialized type objects.)
  47.  
  48. An object has a 'reference count' that is increased or decreased when a
  49. pointer to the object is copied or deleted; when the reference count
  50. reaches zero there are no references to the object left and it can be
  51. removed from the heap.
  52.  
  53. An object has a 'type' that determines what it represents and what kind
  54. of data it contains.  An object's type is fixed when it is created.
  55. Types themselves are represented as objects; an object contains a
  56. pointer to the corresponding type object.  The type itself has a type
  57. pointer pointing to the object representing the type 'type', which
  58. contains a pointer to itself!).
  59.  
  60. Objects do not float around in memory; once allocated an object keeps
  61. the same size and address.  Objects that must hold variable-size data
  62. can contain pointers to variable-size parts of the object.  Not all
  63. objects of the same type have the same size; but the size cannot change
  64. after allocation.  (These restrictions are made so a reference to an
  65. object can be simply a pointer -- moving an object would require
  66. updating all the pointers, and changing an object's size would require
  67. moving it if there was another object right next to it.)
  68.  
  69. Objects are always accessed through pointers of the type 'PyObject *'.
  70. The type 'PyObject' is a structure that only contains the reference count
  71. and the type pointer.  The actual memory allocated for an object
  72. contains other data that can only be accessed after casting the pointer
  73. to a pointer to a longer structure type.  This longer type must start
  74. with the reference count and type fields; the macro PyObject_HEAD should be
  75. used for this (to accomodate for future changes).  The implementation
  76. of a particular object type can cast the object pointer to the proper
  77. type and back.
  78.  
  79. A standard interface exists for objects that contain an array of items
  80. whose size is determined when the object is allocated.
  81. */
  82.  
  83. #ifdef Py_DEBUG
  84.  
  85. /* Turn on heavy reference debugging */
  86. #define Py_TRACE_REFS
  87.  
  88. /* Turn on reference counting */
  89. #define Py_REF_DEBUG
  90.  
  91. #endif /* Py_DEBUG */
  92.  
  93. #ifdef Py_TRACE_REFS
  94. #define PyObject_HEAD \
  95.     struct _object *_ob_next, *_ob_prev; \
  96.     int ob_refcnt; \
  97.     struct _typeobject *ob_type;
  98. #define PyObject_HEAD_INIT(type) 0, 0, 1, type,
  99. #else /* !Py_TRACE_REFS */
  100. #define PyObject_HEAD \
  101.     int ob_refcnt; \
  102.     struct _typeobject *ob_type;
  103. #define PyObject_HEAD_INIT(type) 1, type,
  104. #endif /* !Py_TRACE_REFS */
  105.  
  106. #define PyObject_VAR_HEAD \
  107.     PyObject_HEAD \
  108.     int ob_size; /* Number of items in variable part */
  109.  
  110. typedef struct _object {
  111.     PyObject_HEAD
  112. } PyObject;
  113.  
  114. typedef struct {
  115.     PyObject_VAR_HEAD
  116. } PyVarObject;
  117.  
  118.  
  119. /*
  120. Type objects contain a string containing the type name (to help somewhat
  121. in debugging), the allocation parameters (see newobj() and newvarobj()),
  122. and methods for accessing objects of the type.  Methods are optional,a
  123. nil pointer meaning that particular kind of access is not available for
  124. this type.  The Py_DECREF() macro uses the tp_dealloc method without
  125. checking for a nil pointer; it should always be implemented except if
  126. the implementation can guarantee that the reference count will never
  127. reach zero (e.g., for type objects).
  128.  
  129. NB: the methods for certain type groups are now contained in separate
  130. method blocks.
  131. */
  132.  
  133. typedef PyObject * (*unaryfunc) Py_PROTO((PyObject *));
  134. typedef PyObject * (*binaryfunc) Py_PROTO((PyObject *, PyObject *));
  135. typedef PyObject * (*ternaryfunc) Py_PROTO((PyObject *, PyObject *, PyObject *));
  136. typedef int (*inquiry) Py_PROTO((PyObject *));
  137. typedef int (*coercion) Py_PROTO((PyObject **, PyObject **));
  138. typedef PyObject *(*intargfunc) Py_PROTO((PyObject *, int));
  139. typedef PyObject *(*intintargfunc) Py_PROTO((PyObject *, int, int));
  140. typedef int(*intobjargproc) Py_PROTO((PyObject *, int, PyObject *));
  141. typedef int(*intintobjargproc) Py_PROTO((PyObject *, int, int, PyObject *));
  142. typedef int(*objobjargproc) Py_PROTO((PyObject *, PyObject *, PyObject *));
  143. typedef int (*getreadbufferproc) Py_PROTO((PyObject *, int, void **));
  144. typedef int (*getwritebufferproc) Py_PROTO((PyObject *, int, void **));
  145. typedef int (*getsegcountproc) Py_PROTO((PyObject *, int *));
  146. typedef int (*getcharbufferproc) Py_PROTO((PyObject *, int, const char **));
  147. typedef int (*objobjproc) Py_PROTO((PyObject *, PyObject *));
  148.  
  149. typedef struct {
  150.     binaryfunc nb_add;
  151.     binaryfunc nb_subtract;
  152.     binaryfunc nb_multiply;
  153.     binaryfunc nb_divide;
  154.     binaryfunc nb_remainder;
  155.     binaryfunc nb_divmod;
  156.     ternaryfunc nb_power;
  157.     unaryfunc nb_negative;
  158.     unaryfunc nb_positive;
  159.     unaryfunc nb_absolute;
  160.     inquiry nb_nonzero;
  161.     unaryfunc nb_invert;
  162.     binaryfunc nb_lshift;
  163.     binaryfunc nb_rshift;
  164.     binaryfunc nb_and;
  165.     binaryfunc nb_xor;
  166.     binaryfunc nb_or;
  167.     coercion nb_coerce;
  168.     unaryfunc nb_int;
  169.     unaryfunc nb_long;
  170.     unaryfunc nb_float;
  171.     unaryfunc nb_oct;
  172.     unaryfunc nb_hex;
  173. } PyNumberMethods;
  174.  
  175. typedef struct {
  176.     inquiry sq_length;
  177.     binaryfunc sq_concat;
  178.     intargfunc sq_repeat;
  179.     intargfunc sq_item;
  180.     intintargfunc sq_slice;
  181.     intobjargproc sq_ass_item;
  182.     intintobjargproc sq_ass_slice;
  183.     objobjproc sq_contains;
  184. } PySequenceMethods;
  185.  
  186. typedef struct {
  187.     inquiry mp_length;
  188.     binaryfunc mp_subscript;
  189.     objobjargproc mp_ass_subscript;
  190. } PyMappingMethods;
  191.  
  192. typedef struct {
  193.     getreadbufferproc bf_getreadbuffer;
  194.     getwritebufferproc bf_getwritebuffer;
  195.     getsegcountproc bf_getsegcount;
  196.     getcharbufferproc bf_getcharbuffer;
  197. } PyBufferProcs;
  198.     
  199.  
  200. typedef void (*destructor) Py_PROTO((PyObject *));
  201. typedef int (*printfunc) Py_PROTO((PyObject *, FILE *, int));
  202. typedef PyObject *(*getattrfunc) Py_PROTO((PyObject *, char *));
  203. typedef PyObject *(*getattrofunc) Py_PROTO((PyObject *, PyObject *));
  204. typedef int (*setattrfunc) Py_PROTO((PyObject *, char *, PyObject *));
  205. typedef int (*setattrofunc) Py_PROTO((PyObject *, PyObject *, PyObject *));
  206. typedef int (*cmpfunc) Py_PROTO((PyObject *, PyObject *));
  207. typedef PyObject *(*reprfunc) Py_PROTO((PyObject *));
  208. typedef long (*hashfunc) Py_PROTO((PyObject *));
  209.  
  210. typedef struct _typeobject {
  211.     PyObject_VAR_HEAD
  212.     char *tp_name; /* For printing */
  213.     int tp_basicsize, tp_itemsize; /* For allocation */
  214.     
  215.     /* Methods to implement standard operations */
  216.     
  217.     destructor tp_dealloc;
  218.     printfunc tp_print;
  219.     getattrfunc tp_getattr;
  220.     setattrfunc tp_setattr;
  221.     cmpfunc tp_compare;
  222.     reprfunc tp_repr;
  223.     
  224.     /* Method suites for standard classes */
  225.     
  226.     PyNumberMethods *tp_as_number;
  227.     PySequenceMethods *tp_as_sequence;
  228.     PyMappingMethods *tp_as_mapping;
  229.  
  230.     /* More standard operations (at end for binary compatibility) */
  231.  
  232.     hashfunc tp_hash;
  233.     ternaryfunc tp_call;
  234.     reprfunc tp_str;
  235.     getattrofunc tp_getattro;
  236.     setattrofunc tp_setattro;
  237.  
  238.     /* Functions to access object as input/output buffer */
  239.     PyBufferProcs *tp_as_buffer;
  240.     
  241.     /* Flags to define presence of optional/expanded features */
  242.     long tp_flags;
  243.  
  244.     char *tp_doc; /* Documentation string */
  245.  
  246.     /* More spares */
  247.     long tp_xxx5;
  248.     long tp_xxx6;
  249.     long tp_xxx7;
  250.     long tp_xxx8;
  251.  
  252. #ifdef COUNT_ALLOCS
  253.     /* these must be last */
  254.     int tp_alloc;
  255.     int tp_free;
  256.     int tp_maxalloc;
  257.     struct _typeobject *tp_next;
  258. #endif
  259. } PyTypeObject;
  260.  
  261. extern DL_IMPORT(PyTypeObject) PyType_Type; /* The type of type objects */
  262.  
  263. #define PyType_Check(op) ((op)->ob_type == &PyType_Type)
  264.  
  265. /* Generic operations on objects */
  266. extern DL_IMPORT(int) PyObject_Print Py_PROTO((PyObject *, FILE *, int)) SEG_OBJECT_H;
  267. extern DL_IMPORT(PyObject *) PyObject_Repr Py_PROTO((PyObject *)) SEG_OBJECT_H;
  268. extern DL_IMPORT(PyObject *) PyObject_Str Py_PROTO((PyObject *)) SEG_OBJECT_H;
  269. extern DL_IMPORT(int) PyObject_Compare Py_PROTO((PyObject *, PyObject *)) SEG_OBJECT_H;
  270. extern DL_IMPORT(PyObject *) PyObject_GetAttrString Py_PROTO((PyObject *, char *)) SEG_OBJECT_H;
  271. extern DL_IMPORT(int) PyObject_SetAttrString Py_PROTO((PyObject *, char *, PyObject *)) SEG_OBJECT_H;
  272. extern DL_IMPORT(int) PyObject_HasAttrString Py_PROTO((PyObject *, char *)) SEG_OBJECT_H;
  273. extern DL_IMPORT(PyObject *) PyObject_GetAttr Py_PROTO((PyObject *, PyObject *)) SEG_OBJECT_H;
  274. extern DL_IMPORT(int) PyObject_SetAttr Py_PROTO((PyObject *, PyObject *, PyObject *)) SEG_OBJECT_H;
  275. extern DL_IMPORT(int) PyObject_HasAttr Py_PROTO((PyObject *, PyObject *)) SEG_OBJECT_H;
  276. extern DL_IMPORT(long) PyObject_Hash Py_PROTO((PyObject *)) SEG_OBJECT_H;
  277. extern DL_IMPORT(int) PyObject_IsTrue Py_PROTO((PyObject *)) SEG_OBJECT_H;
  278. extern DL_IMPORT(int) PyObject_Not Py_PROTO((PyObject *)) SEG_OBJECT_H;
  279. extern DL_IMPORT(int) PyCallable_Check Py_PROTO((PyObject *)) SEG_OBJECT_H;
  280. extern DL_IMPORT(int) PyNumber_Coerce Py_PROTO((PyObject **, PyObject **)) SEG_OBJECT_H;
  281. extern DL_IMPORT(int) PyNumber_CoerceEx Py_PROTO((PyObject **, PyObject **)) SEG_OBJECT_H;
  282.  
  283. /* Helpers for printing recursive container types */
  284. extern DL_IMPORT(int) Py_ReprEnter Py_PROTO((PyObject *)) SEG_OBJECT_H;
  285. extern DL_IMPORT(void) Py_ReprLeave Py_PROTO((PyObject *)) SEG_OBJECT_H;
  286.  
  287. /* Flag bits for printing: */
  288. #define Py_PRINT_RAW    1    /* No string quotes etc. */
  289.  
  290. /*
  291.  
  292. Type flags (tp_flags)
  293.  
  294. These flags are used to extend the type structure in a backwards-compatible
  295. fashion. Extensions can use the flags to indicate (and test) when a given
  296. type structure contains a new feature. The Python core will use these when
  297. introducing new functionality between major revisions (to avoid mid-version
  298. changes in the PYTHON_API_VERSION).
  299.  
  300. Arbitration of the flag bit positions will need to be coordinated among
  301. all extension writers who publically release their extensions (this will
  302. be fewer than you might expect!)..
  303.  
  304. Python 1.5.2 introduced the bf_getcharbuffer slot into PyBufferProcs.
  305.  
  306. Type definitions should use Py_TPFLAGS_DEFAULT for their tp_flags value.
  307.  
  308. Code can use PyType_HasFeature(type_ob, flag_value) to test whether the
  309. given type object has a specified feature.
  310.  
  311. */
  312.  
  313. /* PyBufferProcs contains bf_getcharbuffer */
  314. #define Py_TPFLAGS_HAVE_GETCHARBUFFER  (1L<<0)
  315.  
  316. /* PySequenceMethods contains sq_contains */
  317. #define Py_TPFLAGS_HAVE_SEQUENCE_IN (1L<<1)
  318.  
  319. #define Py_TPFLAGS_DEFAULT  (Py_TPFLAGS_HAVE_GETCHARBUFFER | \
  320.                              Py_TPFLAGS_HAVE_SEQUENCE_IN)
  321.  
  322. #define PyType_HasFeature(t,f)  (((t)->tp_flags & (f)) != 0)
  323.  
  324.  
  325. /*
  326. The macros Py_INCREF(op) and Py_DECREF(op) are used to increment or decrement
  327. reference counts.  Py_DECREF calls the object's deallocator function; for
  328. objects that don't contain references to other objects or heap memory
  329. this can be the standard function free().  Both macros can be used
  330. whereever a void expression is allowed.  The argument shouldn't be a
  331. NIL pointer.  The macro _Py_NewReference(op) is used only to initialize
  332. reference counts to 1; it is defined here for convenience.
  333.  
  334. We assume that the reference count field can never overflow; this can
  335. be proven when the size of the field is the same as the pointer size
  336. but even with a 16-bit reference count field it is pretty unlikely so
  337. we ignore the possibility.  (If you are paranoid, make it a long.)
  338.  
  339. Type objects should never be deallocated; the type pointer in an object
  340. is not considered to be a reference to the type object, to save
  341. complications in the deallocation function.  (This is actually a
  342. decision that's up to the implementer of each new type so if you want,
  343. you can count such references to the type object.)
  344.  
  345. *** WARNING*** The Py_DECREF macro must have a side-effect-free argument
  346. since it may evaluate its argument multiple times.  (The alternative
  347. would be to mace it a proper function or assign it to a global temporary
  348. variable first, both of which are slower; and in a multi-threaded
  349. environment the global variable trick is not safe.)
  350. */
  351.  
  352. #ifdef Py_TRACE_REFS
  353. #ifndef Py_REF_DEBUG
  354. #define Py_REF_DEBUG
  355. #endif
  356. #endif
  357.  
  358. #ifdef Py_TRACE_REFS
  359. extern DL_IMPORT(void) _Py_Dealloc Py_PROTO((PyObject *)) SEG_OBJECT_H;
  360. extern DL_IMPORT(void) _Py_NewReference Py_PROTO((PyObject *)) SEG_OBJECT_H;
  361. extern DL_IMPORT(void) _Py_ForgetReference Py_PROTO((PyObject *)) SEG_OBJECT_H;
  362. extern DL_IMPORT(void) _Py_PrintReferences Py_PROTO((FILE *)) SEG_OBJECT_H;
  363. extern DL_IMPORT(void) _Py_ResetReferences Py_PROTO((void)) SEG_OBJECT_H;
  364. #endif
  365.  
  366. #ifndef Py_TRACE_REFS
  367. #ifdef COUNT_ALLOCS
  368. #define _Py_Dealloc(op) ((op)->ob_type->tp_free++, (*(op)->ob_type->tp_dealloc)((PyObject *)(op)))
  369. #define _Py_ForgetReference(op) ((op)->ob_type->tp_free++)
  370. #else /* !COUNT_ALLOCS */
  371. #define _Py_Dealloc(op) (*(op)->ob_type->tp_dealloc)((PyObject *)(op))
  372. #define _Py_ForgetReference(op) /*empty*/
  373. #endif /* !COUNT_ALLOCS */
  374. #endif /* !Py_TRACE_REFS */
  375.  
  376. #ifdef COUNT_ALLOCS
  377. extern DL_IMPORT(void) inc_count Py_PROTO((PyTypeObject *)) SEG_OBJECT_H;
  378. #endif
  379.  
  380. #ifdef Py_REF_DEBUG
  381.  
  382. extern DL_IMPORT(long) _Py_RefTotal;
  383.  
  384. #ifndef Py_TRACE_REFS
  385. #ifdef COUNT_ALLOCS
  386. #define _Py_NewReference(op) (inc_count((op)->ob_type), _Py_RefTotal++, (op)->ob_refcnt = 1)
  387. #else
  388. #define _Py_NewReference(op) (_Py_RefTotal++, (op)->ob_refcnt = 1)
  389. #endif
  390. #endif /* !Py_TRACE_REFS */
  391.  
  392. #define Py_INCREF(op) (_Py_RefTotal++, (op)->ob_refcnt++)
  393. #define Py_DECREF(op) \
  394.     if (--_Py_RefTotal, --(op)->ob_refcnt != 0) \
  395.         ; \
  396.     else \
  397.         _Py_Dealloc((PyObject *)(op))
  398. #else /* !Py_REF_DEBUG */
  399.  
  400. #ifdef COUNT_ALLOCS
  401. #define _Py_NewReference(op) (inc_count((op)->ob_type), (op)->ob_refcnt = 1)
  402. #else
  403. #define _Py_NewReference(op) ((op)->ob_refcnt = 1)
  404. #endif
  405.  
  406. #define Py_INCREF(op) ((op)->ob_refcnt++)
  407. #define Py_DECREF(op) \
  408.     if (--(op)->ob_refcnt != 0) \
  409.         ; \
  410.     else \
  411.         _Py_Dealloc((PyObject *)(op))
  412. #endif /* !Py_REF_DEBUG */
  413.  
  414. /* Macros to use in case the object pointer may be NULL: */
  415.  
  416. #define Py_XINCREF(op) if ((op) == NULL) ; else Py_INCREF(op)
  417. #define Py_XDECREF(op) if ((op) == NULL) ; else Py_DECREF(op)
  418.  
  419. /* Definition of NULL, so you don't have to include <stdio.h> */
  420.  
  421. #ifndef NULL
  422. #define NULL 0
  423. #endif
  424.  
  425.  
  426. /*
  427. _Py_NoneStruct is an object of undefined type which can be used in contexts
  428. where NULL (nil) is not suitable (since NULL often means 'error').
  429.  
  430. Don't forget to apply Py_INCREF() when returning this value!!!
  431. */
  432.  
  433. extern DL_IMPORT(PyObject) _Py_NoneStruct; /* Don't use this directly */
  434.  
  435. #define Py_None (&_Py_NoneStruct)
  436.  
  437.  
  438. /*
  439. A common programming style in Python requires the forward declaration
  440. of static, initialized structures, e.g. for a type object that is used
  441. by the functions whose address must be used in the initializer.
  442. Some compilers (notably SCO ODT 3.0, I seem to remember early AIX as
  443. well) botch this if you use the static keyword for both declarations
  444. (they allocate two objects, and use the first, uninitialized one until
  445. the second declaration is encountered).  Therefore, the forward
  446. declaration should use the 'forwardstatic' keyword.  This expands to
  447. static on most systems, but to extern on a few.  The actual storage
  448. and name will still be static because the second declaration is
  449. static, so no linker visible symbols will be generated.  (Standard C
  450. compilers take offense to the extern forward declaration of a static
  451. object, so I can't just put extern in all cases. :-( )
  452. */
  453.  
  454. #ifdef BAD_STATIC_FORWARD
  455. #define staticforward extern
  456. #ifdef __SC__
  457. #define statichere
  458. #else
  459. #define statichere static
  460. #endif /* __SC__ */
  461. #else /* !BAD_STATIC_FORWARD */
  462. #define staticforward static
  463. #define statichere static
  464. #endif /* !BAD_STATIC_FORWARD */
  465.  
  466.  
  467. /*
  468. More conventions
  469. ================
  470.  
  471. Argument Checking
  472. -----------------
  473.  
  474. Functions that take objects as arguments normally don't check for nil
  475. arguments, but they do check the type of the argument, and return an
  476. error if the function doesn't apply to the type.
  477.  
  478. Failure Modes
  479. -------------
  480.  
  481. Functions may fail for a variety of reasons, including running out of
  482. memory.  This is communicated to the caller in two ways: an error string
  483. is set (see errors.h), and the function result differs: functions that
  484. normally return a pointer return NULL for failure, functions returning
  485. an integer return -1 (which could be a legal return value too!), and
  486. other functions return 0 for success and -1 for failure.
  487. Callers should always check for errors before using the result.
  488.  
  489. Reference Counts
  490. ----------------
  491.  
  492. It takes a while to get used to the proper usage of reference counts.
  493.  
  494. Functions that create an object set the reference count to 1; such new
  495. objects must be stored somewhere or destroyed again with Py_DECREF().
  496. Functions that 'store' objects such as PyTuple_SetItem() and
  497. PyDict_SetItemString()
  498. don't increment the reference count of the object, since the most
  499. frequent use is to store a fresh object.  Functions that 'retrieve'
  500. objects such as PyTuple_GetItem() and PyDict_GetItemString() also
  501. don't increment
  502. the reference count, since most frequently the object is only looked at
  503. quickly.  Thus, to retrieve an object and store it again, the caller
  504. must call Py_INCREF() explicitly.
  505.  
  506. NOTE: functions that 'consume' a reference count like
  507. PyList_SetItemString() even consume the reference if the object wasn't
  508. stored, to simplify error handling.
  509.  
  510. It seems attractive to make other functions that take an object as
  511. argument consume a reference count; however this may quickly get
  512. confusing (even the current practice is already confusing).  Consider
  513. it carefully, it may save lots of calls to Py_INCREF() and Py_DECREF() at
  514. times.
  515. */
  516.  
  517. #ifdef __cplusplus
  518. }
  519. #endif
  520. #endif /* !Py_OBJECT_H */
  521.