This:
newList = array(range(0, count), 'i')
Initializes the array, so there is no reason to loop through the array again with the for loop to assign values (not
sure if that was clear from the previous poster's message).
As for what is wrong with the for loop: I am not sure that there is anything wrong but it is a matter of how he is using
it. Your looping through the values in newList just to assign them to newList again? Seems kind of silly to me as
well.
On a side note: it seems strange that Python's syntax and Jython's syntax for the array() function are different. In
Python the function is defined as array(typecode[, initializer]) wheres in Jython the initializer comes first, followed
by the typecode. Can anyone explain why?
Sincerely,
Anthony Eden
Post by Gordon Scott-----Original Message-----
Scott
Sent: Tuesday, April 09, 2002 12:06 PM
Subject: RE: [Jython-users] Re: Jython panned in JavaWorld article
being a newbie to python and jython myself,
can someone explain what is incorrect about this
for loop?
Thx.
-----Original Message-----
Sent: Tuesday, April 09, 2002 8:28 AM
Cc: Rune Braathen
Subject: Re: [Jython-users] Re: Jython panned in JavaWorld article
Here is his allocArray.py benchmark. The work of assigning values to the
elements is done twice (and his grasp of the 'for' loop isn't quite
right).
from jarray import array
newList = array(range(0, count), 'i')
newList[index] = index
print "done"
bench = 100000;
print "allocating and initializing a ", bench , " element array..."
allocArray(bench);
_______________________________________________
Jython-users mailing list
https://lists.sourceforge.net/lists/listinfo/jython-users