immutable count and index

Grant Griffin not.this at seebelow.org
Mon Aug 13 13:29:07 EDT 2001


In article <mailman.997657944.32355.python-list at python.org>, "Tim says...
>
>[Grant Griffin]
>> Does anybody know why the "count" and "index" methods are available for
>> mutable, but not immutable, sequences?
>> ...
>> I can't say that I use these two much, ...
>
>Bingo.  Code bloat just to stop random questions about things people don't
>actually want anyway isn't worth it <wink>.

That's fair.

I guess I had assumed that the same machinery could be used for both, so there
wouldn't be much bloat.  But maybe lists and tuples are so different
under-the-hood that it would be pure duplication (as I assume is currently the
case for count/index on lists/strings.)

>If you really have to, you can use operator.countOf on tuples.
>
>> To me, it looks like the thing to do would be to make the
>> general more form used by strings available for all sequence types.
>
>SourceForge is open for patches, but be warned that Guido has rejected
>patches of this ilk:
>
>http://sf.net/tracker/?group_id=5470&atid=305470&func=detail&aid=403693
>#403693 tupleobject.c: implement tuple.index() and tuple.count()
>

Specically, if I may quote, Guido says there, "I'm rejecting this in the name of
all those users who want Python to be small."

But by explaining these things once-and-for-all on the "Sequence Types" page, I
figured we might smallmify Python a little from a different angle--in terms of
its documentation <wink>.

Seriously, though, if the various types of immutable sequences don't share much
machinery, maybe the folks Guido refers to can find an opportunity in that to
smallmify Python itself.

minimalism-is-worth-whatever-extra-effort-it-takes-ly y'rs,

=g2

_____________________________________________________________________

Grant R. Griffin                                       g2 at dspguru.com
Publisher of dspGuru                           http://www.dspguru.com
Iowegian International Corporation            http://www.iowegian.com




More information about the Python-list mailing list