[pypy-svn] r72862 - pypy/branch/cpython-extension/pypy/module/cpyext
afa at codespeak.net
afa at codespeak.net
Thu Mar 25 23:46:27 CET 2010
Author: afa
Date: Thu Mar 25 23:46:25 2010
New Revision: 72862
Added:
pypy/branch/cpython-extension/pypy/module/cpyext/c-api.txt (contents, props changed)
Modified:
pypy/branch/cpython-extension/pypy/module/cpyext/TODO
Log:
Update TODO, start a technical documentation
Modified: pypy/branch/cpython-extension/pypy/module/cpyext/TODO
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/TODO (original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/TODO Thu Mar 25 23:46:25 2010
@@ -1,52 +1,20 @@
- - Implement C API.
- Complete the PyTypeObject initialization code.
+
- Use a WeakKeyDictionary to count how often a PyObject is allocated for
a given wrapped object and use this to assess whether optimizations are
useful
+
- lltype.free in PyObject_Del() sometimes raise an exception (but all
- tests pass)
+ tests pass). FIXED?
- Reported by Amaury
- Alexander cannot reproduce it
+ - replace @cpython_api(external=False) by another explicit name: all
+ it does is a lltype function pointer, no C code involved.
-PyStringObject support
-======================
-
-The problem
------------
-
-PyString_AsString() should return a (non-movable) pointer
-to the underlying buffer, whereas pypy strings are movable. C code
-may temporarily store this address and use it, as long as it owns a
-reference to the PyObject. There is no "release" function to specify
-that the pointer is not needed any more.
-
-Note that the pointer may be used to fill the initial value of
-string. This is valid only when the string was just allocated, and is
-not used elsewhere.
-
-Proposed solution
------------------
-
-Our emulation of the PyStringObject contains an additional member: a
-pointer to a char buffer; it may be NULL.
-
-- A string allocated by pypy will be converted into a PyStringObject
- with a NULL buffer. When PyString_AsString() is called, memory is
- allocated (with flavor='raw') and content is copied.
-
-- A string allocated with PyString_FromStringAndSize(NULL, size) will
- allocate a buffer with the specified size, but the reference won't
- be stored in the global map py_objects_r2w; there won't be a
- corresponding object in pypy. When from_ref() or Py_INCREF() is
- called, the pypy string is created, and added in py_objects_r2w.
- The buffer is then supposed to be immutable.
-
-- _PyString_Resize works only on not-yet-pypy'd strings, and returns a
- similar object.
+ - refactor management of py_objects_r2w and py_objects_w2r, this can
+ probably be expressed in terms of _PyObject_GC_TRACK macros.
-- PyString_Size don't need to force the object. (in this case, another
- "size" member is needed)
+ - Use the standard CPython attribute names: ob_type, ob_refcnt.
-- There could be an (expensive!) check in from_ref() that the buffer
- still corresponds to the pypy gc-managed string.
+ - ob_type should be a PyTypeObject.
Added: pypy/branch/cpython-extension/pypy/module/cpyext/c-api.txt
==============================================================================
--- (empty file)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/c-api.txt Thu Mar 25 23:46:25 2010
@@ -0,0 +1,51 @@
+Reference Count
+===============
+
+XXX
+
+Borrowed References
+===================
+
+XXX
+
+PyStringObject support
+======================
+
+The problem
+-----------
+
+PyString_AsString() returns a (non-movable) pointer to the underlying
+buffer, whereas pypy strings are movable. C code may temporarily
+store this address and use it, as long as it owns a reference to the
+PyObject. There is no "release" function to specify that the pointer
+is not needed any more.
+
+Note that the pointer may be used to fill the initial value of
+string. This is valid only when the string was just allocated, and is
+not used elsewhere.
+
+Proposed solution
+-----------------
+
+Our emulation of the PyStringObject contains an additional member: a
+pointer to a char buffer; it may be NULL.
+
+- A string allocated by pypy will be converted into a PyStringObject
+ with a NULL buffer. When PyString_AsString() is called, memory is
+ allocated (with flavor='raw') and content is copied.
+
+- A string allocated with PyString_FromStringAndSize(NULL, size) will
+ allocate a buffer with the specified size, but the reference won't
+ be stored in the global map py_objects_r2w; there won't be a
+ corresponding object in pypy. When from_ref() or Py_INCREF() is
+ called, the pypy string is created, and added in py_objects_r2w.
+ The buffer is then supposed to be immutable.
+
+- _PyString_Resize works only on not-yet-pypy'd strings, and returns a
+ similar object.
+
+- PyString_Size don't need to force the object. (in this case, another
+ "size" member is needed)
+
+- There could be an (expensive!) check in from_ref() that the buffer
+ still corresponds to the pypy gc-managed string.
More information about the Pypy-commit
mailing list