[Edu-sig] Python for CS101

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Fri May 6 20:26:32 CEST 2005


> For instance, to write an efficient queue data structure (where adding
> and removing form the queue are always constant-time operations) in
> LISP/Scheme requires using arrays.

Hi Toby,

I don't think this is a valid criticism.  If the point of using a queue is
to teach how to write an efficient data structure, is the target audience
really going to be beginners?  Do beginners care about efficiency, to the
exclusion of all else?


What you said is also technically wrong: there are efficent ways to
implement queues with pure list structures.  See:

    http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/210459

which is basically a translation of a Lisp-friendly queue class.


The discussion in the link above also shows that it's perfectly easy ---
and all too often likely --- for beginners to do silly things using
Python's lists too.  On Python-tutor, we often do get beginners who will
do things like list.pop(0), and not understand why it goes so slowly,
compared to doing list.pop().

Abstractions always leak.  But I wouldn't say that Python is flawed
because it makes it easy to do list.pop(0), nor would I say Lisp is flawed
because it makes it easy to use linked lists.



More information about the Edu-sig mailing list