Pymacs - tuples/lists .vs. proper-lists/vectors
Brian McErlean
brianmce at crosswinds.net
Mon Sep 17 05:26:23 EDT 2001
More information about the Python-list mailing list
Mon Sep 17 05:26:23 EDT 2001
- Previous message (by thread): Pymacs - tuples/lists .vs. proper-lists/vectors
- Next message (by thread): Pymacs - tuples/lists .vs. proper-lists/vectors
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard) wrote in message news:<mailman.1000689320.30408.python-list at python.org>... > Hi, Pythonres and Pythonras. > > Someone is suggesting that the choice of translating: > > Python to Emacs LISP > > tuples -> proper lists > lists -> vectors > > might not be ideal, and suggests that I change that to: > > Python to Emacs LISP > > tuples -> vectors > lists -> proper lists > > instead. He argues that Python lists are more easy to shrink and expand > than Python tuples, which well parallels Emacs LISP proper lists being > also more flexible than Emacs LISP vectors. I disagree, though given that I did the same thing, maybe I'm just defending my own mistakes. On the surface, python lists seem a bit closer to lisp lists, though they are very different in other ways (eg O(N) access) I think it is more useful to look at how they are used. The way I use lisp lists/tuples, and vectors/python lists is very similar: Tuples / Lisp lists: Used to group small amounts of heterogenous data. Usually 2-10 elements. Rarely used for large structures Access time not too important, due to small number of elements. Python lists / Lisp Vectors: Can contain large amounts of (usually) heterogenous elements. Potentially thousands of elements. O(1) access time important, since there are many elements. While there are patterns I use in python with lists that rely on extending, eg. building lists like: l=[] while cond: <do stuff to get next element> l.append(next_element) I wouldn't use a similar pattern in lisp with either lists or tuples, so I don't think this is an issue. I've seen posts here that use tuples/lists in a similar way in python at least, so its probably worth finding out what more people do in lisp before making a decision. > This might be debated to death, of course. My reasons for the current > choice are rather weak. Maybe I corresponded round parentheses to round > parentheses, and square ones to square ones. This is surely easier to > remember, but maybe not as natural as I would have expected it to be. > So far, I see myself writing `return tuple(result)' a bit too often... Don't underestimate the benefit of similar syntax too. I think it is a useful reminder. > Pymacs is young enough to afford the change suggested above, so I think I'm > going to dive and do it right now. Yet, remains in the back of me a bit > of doubt. Please tell me if I am goofing big by accepting the above change! I think it might be better as it is, but its entirely possible that I'm just weird in this respect. -- Brian McErlean
- Previous message (by thread): Pymacs - tuples/lists .vs. proper-lists/vectors
- Next message (by thread): Pymacs - tuples/lists .vs. proper-lists/vectors
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list