Bug in Python?

Sven R. Kunze srkunze at mail.de
Sun Feb 28 04:52:45 EST 2016


On 26.02.2016 23:37, Ian Kelly wrote:
> On Fri, Feb 26, 2016 at 3:08 PM, Sven R. Kunze <srkunze at mail.de> wrote:
>> Python sometimes seems not to hop back and forth between C and Python code.
> C code as a rule tends to ignore dunder methods. Those are used to
> implement Python operations, not C operations.

Ah, good to know.

>>          _siftup(heap, 0)    # that's C
> Your comment here appears to be incorrect.
>
> [snip]
>
> So I would guess that the difference here is because one
> implementation is entirely C, and the other implementation is entirely
> Python.

You are damn right. While implementing xheap and looking at the C 
implementation, I just assumed that all Python functions would be 
replaced by when the C module is imported. Furthermore, the C module 
exports some internal functions (leading _ ) such as _heappop_max. Thus, 
I assumed this is true for _siftup without verifying it by looking too 
closely at the PyMethodDef and PyModuleDef structs. Sorry for that.

Best,
Sven



More information about the Python-list mailing list