[aklug] Re: Lists

From: Shane R. Spencer <shane@bogomip.com>
Date: Tue Jul 26 2011 - 09:12:59 AKDT

If I'm not mistaken. Python list/tuple objects have a length integer attribute that gets
incremented/decremented as needed. Python lists are really well implemented as far as I'm
concerned thanks to how it's indexed.. however they chew up a bit more memory.

I think it's pretty good practice to resolve small bits of information as objects change
to allow fast read access.

On 07/26/2011 07:26 AM, Tim Johnson wrote:
> * Christopher Howard <christopher.howard@frigidcode.com> [110725 20:57]:
>> Question for the Perl programmers and the Python programmers: in either
>> language, can you re-implement the length function for lists? (Without
>> actually using the built-in length function, of course.)
>
> python has builtin functions and `len()' is one.
>
> python has something called `special methods' and `__len()__ is
> one.
>
> Therefore you can define a class with a __len__() method,
> instantiate an object from the class, and execute the method
> by calling len() with the instance as an argument.
>

---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.
Received on Tue Jul 26 09:12:58 2011

This archive was generated by hypermail 2.1.8 : Tue Jul 26 2011 - 09:12:58 AKDT