[python-win32] advice on architecting or program design in python:

Tim Golden mail at timgolden.me.uk
Tue Mar 11 14:03:42 CET 2008


mark.a.brand wrote:
> Hi Tim:
> 
> Thanks, that was what I was after, but maybe you are right a couple of extra
> for loops is not looking too bad after all.

The code looks a little scary at first sight but it's
not that bad ;)

It's one of those things everyone learns to weigh up when
they're putting together code / data. How "clever" do I
try to be. Sometimes there's clear benefit (or at least
no clear disadvantage). Other times it's the result of
overengineering -- and often up front. You may find, for
example, that the .executemany in the sqlite example gives
a performance benefit over Elixir's more explicit looping,
but you might not (or it might not be significant). Go
with what's clearest first, then look for optimisations where
you really need them.

[One of] The great thing[s] about Python is that refactoring
is usually really easy. The two solutions I outlined did
(broadly) the same thing. You could make them even more
similar with a little work. Each one is only a couple of
dozens of lines of code. If you started with one and decided
later that the other was preferable, it would be really simple
to swap one out and the other in. Obviously, it's not always
that easy but it's certainly easi*er*.

Good luck with the project. Do come back for more help
(or hindrance).

TJG


More information about the python-win32 mailing list