chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] length performance


From: Kon Lovett
Subject: Re: [Chicken-users] length performance
Date: Wed, 4 Jan 2006 16:41:26 -0800

Lists are not the central datatype in Python that they are in LISPs (LISt Processor), like Chicken Scheme. Contructors & mutators operate much more frequently than (length). In my collection of Scheme code (3396 files, not unique) it is used an average of once!

The requirement for O(1) (length) just isn't very common. In any case it is straightforward to code.

Best Wishes,
Kon


On Jan 4, 2006, at 9:56 AM, Mario Domenech Goulart wrote:

Hello

I've noticed that the performance of the length function is a bit low
for medium/large lists.  As far as I understand (from runtime.c
C_i_length), Chicken counts the elements from the given list everytime
length is invoked.  Is it like that?

If so, wouldn't it be better to have a list attribute which keeps the
number of elements? So, the cost of invoking length would be nearly the
cost of accessing a variable (of course, there is the cost of keeping
the attribute up-to-date whenever an insertion/removal occurs and the
memory usage).  I think Python uses this approach.

What do you think?

Best wishes.
Mario


_______________________________________________
Chicken-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/chicken-users





reply via email to

[Prev in Thread] Current Thread [Next in Thread]