Enums and Python

Dan Schmidt dfan at harmonixmusic.com
Wed Jun 21 15:39:44 EDT 2000


"William Dandreta" <wjdandreta at worldnet.att.net> writes:

| I've come to the conclusion that Python is not an inherently slow
| language but it is very easy to add overhead that makes Python
| programs run extremely slowly. It is much more difficult to do that
| in the other languages that I use. So for the present, I am being
| overly cautious about adding overhead.  As I become more familiar
| with Python, I'm sure that will dissippate.

Yep, what you say is true.  But I would urge you not to be afraid of
using dictionaries, as the expressivity they allow is one of the
things that makes writing in languages like Python and Perl such a
pleasure.

Also, because pretty much everything in Python is implemented with
dictionaries, they can't be _too_ slow :)

| Also, for the simple comma delimited ASCII files that I have been
| manipulated, using 10 to 15 line Python scripts, creating objects
| seems like over kill to me.

OK, here we go again :)

Creating objects in Python is really easy, compared to C++.

Here's a class:

  class Foo: pass

And here's me using it:

  x = Foo()
  x.date = "21 Jun 2000"
  x.id = 8675309

In this case, Foo is really nothing more than a dictionary with
possibly nicer syntax.

Anyway, my point is just that objects are lightweight enough (from a
source point of view) that it's generally not a big deal to use them
even in a script of only one or two dozen lines.

-- 
                 Dan Schmidt | http://www.dfan.org
Honest Bob CD now available! | http://www.dfan.org/honestbob/cd.html



More information about the Python-list mailing list