Dick Moores wrote: > Kent Johnson wrote at 10:37 10/11/2005: >>The reason psyco doesn't make much difference is because all the time is >>spent in list.count() which is already C code. > > > Ah. But how can I know what is in C code and what isn't? For example, in > a previous post you say that L.extend(e) is in C, and imply that > L.append(e) isn't, and that therefore L.extend(e) should be used.
In general, if you wrote it, it's in Python. If it is built-in - either as part of the Python syntax or pretty much anything in chapter 2 of the Python Library Reference - it's in C. If it is in the standard lib (anything you import) you have to look at the lib module to see how it is implemented - some are in Python, some are in C. Both extend() and append() are part of the built-in type 'list' so they are in C. The difference is that to use append() you have to put a loop around it, the loop is in your Python code. If you use extend() the loop is implicit (in extend()) and implemented as part of extend(). Kent _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor