[SciPy-user] What can be improved ?

Gael Varoquaux gael.varoquaux at normalesup.org
Thu May 17 08:33:20 EDT 2007


On Thu, May 17, 2007 at 12:11:27PM +0200, Stef Mientki wrote:
> And here are some aspects, for which I still have doubts or questions:
> - from .... import *
> the use of this construct is discouraged, and gives a warning (the only 
> warning I get is from David ;-)
> Coming from Delphi, it's very common to include everything you've available,
> so you never have to worry missing something,
> and if included in the right order,
> you are guaranteed to have the best version of everything (due to 
> overrides),
> while you're still able to use older/previous libraries, by explictly 
> naming them.
> The compiler will sort out everything you don't need.
> So what's so different in Python, that I can't include everything that's 
> on my PC ?

Well I think that in Delphi if you already have a function "max" and you
try to import a module with a function "max" defined in it, Delphi is
going to complain. Am I right ? Well in Python, it is not the case, so if
you have done a large number of "from ... import *", you have no way of
knowing where "max" comes from. What people often do is 
"import numpy as N". They can call "N.max", afterwards.

> - use CSV, yes but how should I've known ?
> I think (and it's mentioned before by others) this is one of the major 
> problems of Python,
> "where should I find something ?". I've read the book "Learning Python", 
> but nothing is mentioned about CSV :-(

Google, I would say. Yes there is no good solution. People are starting
to work on building a help database, but it is not an easy job, and it
will be a few years before it works.

> - better to use an object than a function
> Yes I've thought about that, but I had one major concern why I didn't 
> choose for an object (besides the fact that in the beginning I assumed 
> the function to be much smaller), and that concern is memory usage. I 
> also never see something as a "closefile()" ??

You no what they say ? Premature optimization is the root of all evil.
Worry about efficiency only if you have an efficiency problem, and if so
do it in a scientific way: profile. I would be surprised to find that
method lookup will be what slows down your code, in the case we are
talking about.

> I've never understood how objects are freed/destroyed in Python.

Well there is a good article about that:

http://www.informit.com/articles/article.asp?p=453682&rl=1

section 3 is what answers your question, but the whole article is worth
reading.

HTH,

Gaël



More information about the SciPy-User mailing list