This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author beng94
Recipients Dustin.Oprea, beng94, martin.panter, meador.inge
Date 2016-02-04.23:49:59
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1454629800.28.0.962034036562.issue21328@psf.upfronthosting.co.za>
In-reply-to
Content
I've added a patch, that solves the problem with the built-in len. Even if it turns out that this functionality is not needed, it was quite of a challenge to track down the issue, I've learned a lot. :)

Here are some functions, that I looked through, might be useful for someone, who'd like to look into this issue.

https://github.com/python/cpython/blob/master/Python/bltinmodule.c#L1443
static PyObject *
builtin_len(PyModuleDef *module, PyObject *obj)
/*[clinic end generated code: output=8e5837b6f81d915b input=bc55598da9e9c9b5]*/
{
    Py_ssize_t res;

    res = PyObject_Size(obj);
    if (res < 0 && PyErr_Occurred())
        return NULL;
    return PyLong_FromSsize_t(res);
}

https://github.com/python/cpython/blob/master/Objects/abstract.c#L42
Py_ssize_t
PyObject_Size(PyObject *o)
{
    /*...*/
    m = o->ob_type->tp_as_sequence;
    if (m && m->sq_length)
        return m->sq_length(o);
    /*...*/
}

https://github.com/python/cpython/blob/master/Modules/_ctypes/_ctypes.c#L4449
static PySequenceMethods Array_as_sequence = {
    Array_length,                               /* sq_length; */
    /*...*/
};

https://github.com/python/cpython/blob/master/Modules/_ctypes/_ctypes.c#L4442
static Py_ssize_t
Array_length(PyObject *myself)
{
    CDataObject *self = (CDataObject *)myself;
    return self->b_length;
}
History
Date User Action Args
2016-02-04 23:50:00beng94setrecipients: + beng94, meador.inge, martin.panter, Dustin.Oprea
2016-02-04 23:50:00beng94setmessageid: <1454629800.28.0.962034036562.issue21328@psf.upfronthosting.co.za>
2016-02-04 23:50:00beng94linkissue21328 messages
2016-02-04 23:50:00beng94create