Creating a list/tuple/dictionary

Andrew Wilkinson ajw126NO at SPAMyork.ac.uk
Tue Jan 7 15:26:59 CET 2003


Hi,

When the Python interpreter comes across a statement such as...

a = [1,2,3]

how does it go about creating that list?

Does it convert the code into something equivalent to
a = []
a.append(1)
a.append(2)
a.append(3)
(although obviously it would call the C functions directly)

or is there a quicker method that it uses, if so is that accessible from
ordinary python code?

The same question applies to tuples and dictionaries, although I'm guess
that the same answer will apply to all of them.

thanks in advance,
Andrew Wilkinson








More information about the Python-list mailing list