Message133026
I may have found another use case for this functionality. Currently, the Python code in heapq.py accepts arbitrary sequences (that are sufficiently compatible with the Sequence ABC), but the C code in _heapq only permits use of a concrete list.
The two currently available approaches to address that discrepancy are:
1. Use PyObject_* calls instead of PyList_* calls throughout the code (yuck, we'd be making the common case significantly worse in the name of semantic purity)
2. Sprinkle type checks throughout the _heapq code to decide whether or not to call the concrete APIs or their abstract equivalents
The extensive use of the PyList macro API in _heapq means that a little bit of 2 might still be necessary even if the concrete API was updated as Raymond suggests, but I think there would be value in changing the meaning of the concrete APIs to include falling back to the abstract APIs if the type assumption is incorrect. |
|
Date |
User |
Action |
Args |
2011-04-05 12:24:27 | ncoghlan | set | recipients:
+ ncoghlan, rhettinger, pitrou, eric.araujo, Trundle, daniel.urban |
2011-04-05 12:24:27 | ncoghlan | set | messageid: <1302006267.12.0.189797992305.issue10977@psf.upfronthosting.co.za> |
2011-04-05 12:24:26 | ncoghlan | link | issue10977 messages |
2011-04-05 12:24:26 | ncoghlan | create | |
|