Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #24381

Re: How can i call array_length to get the length of array object?

References <1340504596.65359.YahooMailClassic@web164606.mail.gq1.yahoo.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date 2012-06-23 23:34 -0600
Subject Re: How can i call array_length to get the length of array object?
Newsgroups comp.lang.python
Message-ID <mailman.1440.1340516098.4697.python-list@python.org> (permalink)

Show all headers | View raw


On Sat, Jun 23, 2012 at 8:23 PM, gmspro <gmspro@yahoo.com> wrote:
> I'm trying to call this function, http://hg.python.org/cpython/file/3b7230997425/Modules/arraymodule.c#l657
>
> Is that possible to call that function?
>
> I know it's possible to do:
> >>>len(arr)

You call it just like that.  array_length is the C implementation of
__len__ for arrays.

> Doesn't it call this :
> http://hg.python.org/cpython/file/c0eab397f098/Python/bltinmodule.c#l1283
> instead of this:
> http://hg.python.org/cpython/file/3b7230997425/Modules/arraymodule.c#l657

Yes, and builtin_len calls PyObject_Size, which in turn calls the
object's sq_length method, which is defined to be array_length for
arrays.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: How can i call array_length to get the length of array object? Ian Kelly <ian.g.kelly@gmail.com> - 2012-06-23 23:34 -0600

csiph-web