intentional tease ( was: New Python User Question)

Marcin 'Qrczak' Kowalczyk qrczak at knm.org.pl
Mon Aug 27 22:38:10 CEST 2001


27 Aug 2001 10:48:13 -0700, Grant Griffin <not.this at seebelow.org> pisze:

> However, in working on my little project, I've realized that even
> leaving dynamic variables aside, certain things in the design of
> Python are inherently "slow".  A simple example is the fact that
> Python allows negative array indices.  When implementing that,
> one can only check for a negative index, then add the length.
> And even if it wasn't negative, you have to bounds-check the result,
> to possibly raise an IndexError.  (An "assert" won't do: the Python
> code might have been written to rely on an IndexError.)

For this very problem it helps to use iteration protocols instead of
indexing where possible.

Unfortunately there are other issues, e.g. using zip instead of
indexing two sequences by the same index currently creates many
temporary pair objects. But at least bounds checking and handling
negative indices can be eliminated without sophisticated analysis of
possible values of variables holding numbers.

Having bulk functions for iteration over arrays helped me to eliminate
many bounds checking in Glasgow Haskell Compiler's array implementation.

-- 
 __("<  Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/
 \__/
  ^^                      SYGNATURA ZASTĘPCZA
QRCZAK



More information about the Python-list mailing list