Project organization and import

Martin Unsal martinunsal at gmail.com
Tue Mar 6 02:35:00 EST 2007


On Mar 5, 11:06 am, "Chris Mellon" <arka... at gmail.com> wrote:
> I never advocated big files with many functional units - just files
> that are "just big enough".

Then we're in total agreement. I'm not sure why you thought my
opinions were the result of baggage from other languages when you
don't seem to actually disagree with me.

> Fewer dependencies between compilation units means a
> faster rebuild-test turnaround.

I know all about incremental builds and I just don't think people use
small compilation units in C++ to make their builds faster. It
certainly never been the reason why I subdivided a source file.

> Sure, but whats your goal here? If you're just testing something as
> you work, then this works fine. If you're testing large changes, that
> affect many modules, then you *need* to reload your world, because you
> want to make sure that what you're testing is clean.

I don't think reload works for anything but trivial scripts. The
moment you use "from foo import bar" reload is broken.

> The semantics of exactly what reload should do are tricky. Pythons
> reload works in a sensible but limited way.

I agree that there is some subtlety there, and I appreciate your
example. However the fact that Python's module system essentially
forces you to use "from foo import *" and that reload is almost
entirely imcompatible with "from foo import *", I would say that
reload is essentially useless.

> That said, nothing prevents you from using "from foo import Foo" if
> Foo is all you need (or need most - you can combine this with import
> foo).

Well "from foo import Foo" is just a special case of "from foo import
*". :) It still breaks reload. It still means you're restarting your
interpreter even to do the most trivial development cycle.

> I wonder what environments you worked in before that actually had a
> reliable and gotcha free version of reload?

I'm perfectly well aware that I'm not going to be able to reload a
widget in the middle of a running GUI app, for example. I'm not
looking for gotcha free, I'll settle for minimally useful.

Here's an analogy. In C, you can do an incremental build and run your
modified application without having to first reboot your computer. In
Python, where reload() is essentially the incremental build process,
and the interpreter is essentially a virtual machine, you guys are
saying that my best option is to just "reboot" the virtual machine to
make sure I have a "clean slate". It may be the path of least
resistance, but to say that it is necessary or inevitable is 1960s
mainframe thinking.

Martin




More information about the Python-list mailing list