Top.Mail.Ru
Python
? ?
LiveJournal for python.
View:Personal Journal.
View:Friends.
View:Calendar.
Missed some entries? Then simply jump to the previous day or the next day.

Monday, January 10th, 2005

Subject:Efficient way to initialize array?
Time:11:53 pm.
Is the following an efficient way to create a list of size n, each element initialized with value?

data = n * [value]

What's the idiomatic way of accomplishing this?

Is the following an efficient way to create an array with the same requirements?

import array
data = n * array.array('B', [value])


Thank you.
Comments: Read 2 orAdd Your Own.

LiveJournal for python.

View:User Info.
View:Friends.
View:Calendar.
View:Memories.
Missed some entries? Then simply jump to the previous day or the next day.

Image