The Artima Developer Community
Sponsored Link

Python Buzz Forum
Take Off And Refactor The Script From Orbit

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Ben Last

Posts: 247
Nickname: benlast
Registered: May, 2004

Ben Last is no longer using Python.
Take Off And Refactor The Script From Orbit Posted: Jun 4, 2004 3:48 AM
Reply to this message Reply

This post originated from an RSS feed registered with Python Buzz by Ben Last.
Original Post: Take Off And Refactor The Script From Orbit
Feed Title: The Law Of Unintended Consequences
Feed URL: http://benlast.livejournal.com/data/rss
Feed Description: The Law Of Unintended Consequences
Latest Python Buzz Posts
Latest Python Buzz Posts by Ben Last
Latest Posts From The Law Of Unintended Consequences

Advertisement
One of my more tortuous movie requotings, methinks. The massive network of objects linked by similarity that I rattled on about the other day (how tediously self-referential of me) has been bugging me, in the same way as a chocolate bar, as yet uneaten, can bug you from a cupboard three flights of stairs away. It's the code that compares objects, to be exact. Much clever nesting of comparisons so that only the necessary queries are made; excessively clever, in the way that a model cathedral made entirely of toothpicks is excessive. It's not elegant, it's baroque.

Or rather, it was, for it's all gone. In its place is a solution based on the excellent Python sets module. Every object is a member of one of around thirty different sets. Similarity is then calculated in one single loop that works on set intersections. The processing time is up by a factor of 1.1, but the similarity method is now just six lines as opposed to a pageful. I'll take that trade, since the attributes that define similarity grow in number every week as we discover yet more ways to describe them, but runtime for this script is, essentially, free.

I haven't really had any call to us the level of Python in which sets resides. I think of it as a sort of abstract mathematical zone, suspended above clouds in the dim and distant sky above me, where modules like cmath and mpz live. A realm visited only by those who take the mathematical approach to software; you know, the kind of people who will discuss np completion over beers. I belong to another set; the set of programmers who started with individual ones and zeroes (well, practically, my first computer was one of these) and tend to take a more mechanical attitude to development.

Naturally, like all sweeping generalizations, this is oversimplistic[1]; the sets of developers overlap considerably. Nevertheless, I think there's validity in drawing this distinction; the first set seeing algorithms in terms of the mathematics behind them, the other considering the execution, visualizing it on a sort on in-head virtual machine. Counting myself squarely amongst the second set, I've learned a great deal from the first, especially that O(n!) is a term of abuse...

Moving right along to another subject (the ADHD is a bitch), I found this little article on Game Scripting In Python of interest, as well as this on the same author. The PlayStation Project I'm involved with needs some form of scripting language, and whilst the choice of tools is affected by far more than my personal preference, there might be a role for Python on the console as well as the back-end servers that massage the database. I like the Humungous products; Daughter has had hours (days, even) of fun Pajama Samming and Freddy Fishing, so it's nice to know that there's more to Python and gaming than, um, PyGame.

[1] Of course it's self-referential :)

Read: Take Off And Refactor The Script From Orbit

Topic: Omniscient Debugging Previous Topic   Next Topic Topic: Walking Backwards For Christmas

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use