| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 9de620e commit bed6891
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -52,11 +52,15 @@ The first bit that will be new is:: | |||
| 52 | 52 | } noddy_NoddyObject; | |
| 53 | 53 | ||
| 54 | 54 | This is what a Noddy object will contain---in this case, nothing more than what | |
| 55 | - every Python object contains---a refcount and a pointer to a type object. | ||
| 56 | - These are the fields the ``PyObject_HEAD`` macro brings in. The reason for the | ||
| 57 | - macro is to standardize the layout and to enable special debugging fields in | ||
| 58 | - debug builds. Note that there is no semicolon after the ``PyObject_HEAD`` | ||
| 59 | - macro; one is included in the macro definition. Be wary of adding one by | ||
| 55 | + every Python object contains---a field called ``ob_base`` of type | ||
| 56 | + :c:type:`PyObject`. :c:type:`PyObject` in turn, contains an ``ob_refcnt`` | ||
| 57 | + field and a pointer to a type object. These can be accessed using the macros | ||
| 58 | + :c:macro:`Py_REFCNT` and :c:macro:`Py_TYPE` respectively. These are the fields | ||
| 59 | + the :c:macro:`PyObject_HEAD` macro brings in. The reason for the macro is to | ||
| 60 | + standardize the layout and to enable special debugging fields in debug builds. | ||
| 61 | + | ||
| 62 | + Note that there is no semicolon after the :c:macro:`PyObject_HEAD` macro; | ||
| 63 | + one is included in the macro definition. Be wary of adding one by | ||
| 60 | 64 | accident; it's easy to do from habit, and your compiler might not complain, | |
| 61 | 65 | but someone else's probably will! (On Windows, MSVC is known to call this an | |
| 62 | 66 | error and refuse to compile the code.) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments