On Sun, Jan 5, 2014 at 2:52 AM, Mark Lawrence <breamore...@yahoo.co.uk>wrote:
> Homework for you :) Write a line of code that creates a list of say 3 or > 4 integers, then write a line that creates a tuple with the same integers. > Use the dis module to compare the byte code that the two lines of code > produce. The difference is interesting. Well... that was a very interesting assignment, though I'm going to have to chew on it for a while to understand. I can see that the processing code for a tuple is considerably shorter... it is processed in a gulp instead of bite by byte... it doesn't have the "Build List" step at all (what goes on inside of THAT?)... but I can't claim to really understand what I'm looking at. I notice, for example, if I include only constants (immutable types) in my tuple, then it does that gulp thing. If I include a list in there too, all hell breaks loose, and suddenly I'm Building Tuples (what goes on inside of THAT?). A tuple of tuples still goes down in a single swallow, of course. Sadly, you can see how my mind works here... hey, this was FUN! You can assign me homework any time, teach! -- Keith
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor