<feed xmlns='http://www.w3.org/2005/Atom'>
<title>python.git/Objects/listobject.c, branch v2.4a2</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.</subtitle>
<id>http://dangofactory.net/cgit/cgit.cgi/Server/python.git/atom/Objects/listobject.c?h=v2.4a2</id>
<link rel='self' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/atom/Objects/listobject.c?h=v2.4a2'/>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/'/>
<updated>2004-08-03T04:53:29Z</updated>
<entry>
<title>Tweak previous patch to silence a warning about the unused left value in the</title>
<updated>2004-08-03T04:53:29Z</updated>
<author>
<name>Brett Cannon</name>
<email>bcannon@gmail.com</email>
</author>
<published>2004-08-03T04:53:29Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=5ad28e14b60b32e19ecf54b87aae5f02bac6b361'/>
<id>urn:sha1:5ad28e14b60b32e19ecf54b87aae5f02bac6b361</id>
<content type='text'>
comma expression in listpop() that was being returned.  Still essentially
unused (as it is meant to be), but now the compiler thinks it is worth
*something* by having it incremented.
</content>
</entry>
<entry>
<title>list_ass_slice():  Document the obscure new intent that deleting a slice</title>
<updated>2004-07-31T21:53:19Z</updated>
<author>
<name>Tim Peters</name>
<email>tim.peters@gmail.com</email>
</author>
<published>2004-07-31T21:53:19Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=8fc4a916658aa4a24f29a6e1b438f910465cc22b'/>
<id>urn:sha1:8fc4a916658aa4a24f29a6e1b438f910465cc22b</id>
<content type='text'>
of no more than 8 elements cannot fail.

listpop():  Take advantage of that its calls to list_resize() and
list_ass_slice() can't fail.  This is assert'ed in a debug build now, but
in an icky way.  That is, you can't say:

	assert(some_call() &gt;= 0);

because then some_call() won't occur at all in a release build.  So it
has to be a big pile of #ifdefs on Py_DEBUG (yuck), or the pleasant:

        status = some_call();
        assert(status &gt;= 0);

But in that case, compilers may whine in a release build, because status
appears unused then.  I'm not certain the ugly trick I used here will
convince all compilers to shut up about status (status is always "used" now,
as the first (ignored) clause in a comma expression).
</content>
</entry>
<entry>
<title>list_ass_slice():  The difference between "recycle" and "recycled" was</title>
<updated>2004-07-31T02:54:42Z</updated>
<author>
<name>Tim Peters</name>
<email>tim.peters@gmail.com</email>
</author>
<published>2004-07-31T02:54:42Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=7357222d0e441725d6d8ccd7269a542ac340de89'/>
<id>urn:sha1:7357222d0e441725d6d8ccd7269a542ac340de89</id>
<content type='text'>
impossible to remember, so renamed one to something obvious.  Headed
off potential signed-vs-unsigned compiler complaints I introduced by
changing the type of a vrbl to unsigned.  Removed the need for the
tedious explanation about "backward pointer loops" by looping on an
int instead.
</content>
</entry>
<entry>
<title>Armin asked for a list_ass_slice review in his checkin, so here's the</title>
<updated>2004-07-31T02:24:20Z</updated>
<author>
<name>Tim Peters</name>
<email>tim.peters@gmail.com</email>
</author>
<published>2004-07-31T02:24:20Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=8d9eb10c299cfaf2f4f8c887ead55da0d24d5050'/>
<id>urn:sha1:8d9eb10c299cfaf2f4f8c887ead55da0d24d5050</id>
<content type='text'>
result.

list_resize():  Document the intent.  Code is increasingly relying on
subtle aspects of its behavior, and they deserve to be spelled out.

list_ass_slice():  A bit more simplification, by giving it a common
error exit and initializing more values.

Be clearer in comments about what "size" means (# of elements?  # of
bytes?).

While the number of elements in a list slice must fit in an int, there's
no guarantee that the number of bytes occupied by the slice will.  That
malloc() and memmove() take size_t arguments is a hint about that &lt;wink&gt;.
So changed to use size_t where appropriate.

ihigh - ilow should always be &gt;= 0, but we never asserted that.  We do
now.

The loop decref'ing the recycled slice had a subtle insecurity:  C doesn't
guarantee that a pointer one slot *before* an array will compare "less
than" to a pointer within the array (it does guarantee that a pointer
one beyond the end of the array compares as expected).  This was actually
an issue in KSR's C implementation, so isn't purely theoretical.  Python
probably has other "go backwards" loops with a similar glitch.
list_clear() is OK (it marches an integer backwards, not a pointer).
</content>
</entry>
<entry>
<title>This is a reorganization of list_ass_slice().  It should probably be reviewed,</title>
<updated>2004-07-30T11:38:22Z</updated>
<author>
<name>Armin Rigo</name>
<email>arigo@tunes.org</email>
</author>
<published>2004-07-30T11:38:22Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=1dd04a02e03e1765d9f2096d979de92927337dcb'/>
<id>urn:sha1:1dd04a02e03e1765d9f2096d979de92927337dcb</id>
<content type='text'>
though I tried to be very careful.  This is a slight simplification, and it
adds a new feature: a small stack-allocated "recycled" array for the cases
when we don't remove too many items.

It allows PyList_SetSlice() to never fail if:
* you are sure that the object is a list; and
* you either do not remove more than 8 items, or clear the list.

This makes a number of other places in the source code correct again -- there
are some places that delete a single item without checking for MemoryErrors
raised by PyList_SetSlice(), or that clear the whole list, and sometimes the
context doesn't allow an error to be propagated.
</content>
</entry>
<entry>
<title>What if you call lst.__init__() while it is being sorted?  :-)</title>
<updated>2004-07-30T11:20:18Z</updated>
<author>
<name>Armin Rigo</name>
<email>arigo@tunes.org</email>
</author>
<published>2004-07-30T11:20:18Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=a37bbf2e5bf9d0854a774cdd1a972d0b7cc9e733'/>
<id>urn:sha1:a37bbf2e5bf9d0854a774cdd1a972d0b7cc9e733</id>
<content type='text'>
The invariant checks would break.
</content>
</entry>
<entry>
<title>* Simplify and speed-up list_resize().  Relying on the newly documented</title>
<updated>2004-07-29T23:31:29Z</updated>
<author>
<name>Raymond Hettinger</name>
<email>python@rcn.com</email>
</author>
<published>2004-07-29T23:31:29Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=c0aaa2db4f7c33c490f91d00c894ffa6395c74fc'/>
<id>urn:sha1:c0aaa2db4f7c33c490f91d00c894ffa6395c74fc</id>
<content type='text'>
  invariants allows the ob_item != NULL check to be replaced with an
  assertion.

* Added assertions to list_init() which document and verify that the
  tp_new slot establishes the invariants.  This may preclude a future
  bug if a custom tp_new slot is written.
</content>
</entry>
<entry>
<title>* drop the unreasonable list invariant that ob_item should never come back</title>
<updated>2004-07-29T12:40:23Z</updated>
<author>
<name>Armin Rigo</name>
<email>arigo@tunes.org</email>
</author>
<published>2004-07-29T12:40:23Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=93677f075df9a23c036f4baeb2b9f67c784eadbc'/>
<id>urn:sha1:93677f075df9a23c036f4baeb2b9f67c784eadbc</id>
<content type='text'>
  to NULL during the lifetime of the object.

* listobject.c nevertheless did not conform to the other invariants,
  either; fixed.

* listobject.c now uses list_clear() as the obvious internal way to clear
  a list, instead of abusing list_ass_slice() for that.  It makes it easier
  to enforce the invariant about ob_item == NULL.

* listsort() sets allocated to -1 during sort; any mutation will set it
  to a value &gt;= 0, so it is a safe way to detect mutation.  A negative
  value for allocated does not cause a problem elsewhere currently.
  test_sort.py has a new test for this fix.

* listsort() leak: if items were added to the list during the sort, AND if
  these items had a __del__ that puts still more stuff into the list,
  then this more stuff (and the PyObject** array to hold them) were
  overridden at the end of listsort() and never released.
</content>
</entry>
<entry>
<title>Minor memory leak.</title>
<updated>2004-07-29T10:56:55Z</updated>
<author>
<name>Armin Rigo</name>
<email>arigo@tunes.org</email>
</author>
<published>2004-07-29T10:56:55Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=f414fc4004fde1118f15efe73f93e2d12d91d82c'/>
<id>urn:sha1:f414fc4004fde1118f15efe73f93e2d12d91d82c</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Fix obscure breakage (relative to 2.3) in listsort:  the test for list</title>
<updated>2004-07-29T04:07:15Z</updated>
<author>
<name>Tim Peters</name>
<email>tim.peters@gmail.com</email>
</author>
<published>2004-07-29T04:07:15Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=51b4ade30615dccaa7f591456528821f4320d5ff'/>
<id>urn:sha1:51b4ade30615dccaa7f591456528821f4320d5ff</id>
<content type='text'>
mutation during list.sort() used to rely on that listobject.c always
NULL'ed ob_item when ob_size fell to 0.  That's no longer true, so the
test for list mutation during a sort is no longer reliable.  Changed the
test to rely instead on that listobject.c now never NULLs-out ob_item
after (if ever) ob_item gets a non-NULL value.  This new assumption is
also documented now, as a required invariant in listobject.h.

The new assumption allowed some real simplification to some of the
hairier code in listsort(), so is a Good Thing on that count.
</content>
</entry>
</feed>
