[SciPy-user] [Newbie] High-performance plotting of large datasets

Gael Varoquaux gael.varoquaux@normalesup....
Mon Mar 3 13:53:43 CST 2008


On Mon, Mar 03, 2008 at 08:21:52PM +0100, Stef Mientki wrote:
> What I understand is that traits is a smart replacement of   "*arg, 
> **kwargs"
> (which I've never used either).
> But being a smart replacement, it also makes it a complex / difficult 
> replacement.

Well, its much more than that.

Traits can be seen as three things:

* Type validation of attributes: the attributes of an object can be given
  a type descriptor (more precisely a validation method) and the
  compliance of the attribute is checked at run-time when this attribute
  is set. This is very useful for complex codebase, but probably not for
  you.

* Reactive/callback programming made easy. When you set the attribute of
  a HasTtraits object, a method of the object can be called to handle
  this change. This is known as reactive programming and is a great
  programming pattern that makes your code easier to read and more modular.
  I couldn't stress this more.

* Visualization made easy: from the two bullet points above, TraitsUI can
  generate interactive dialogs. The automatic generation of dialogs
  combined with the reactive programming makes the codebase very light and
  nice to read.

> but as follower of the KISS principle, again I don't understand it.

KISS is great, but remember: 1 month of hard work can save you one week
end of learning. If you start doing interactive GUIs, you won't be able
to get around learning a few things, and I think it is easier to learn
Traits than the alternatives.

> Please tell me in 2 lines what's the essential difference between TraitsUI 
> in your presentation,
> and the lines below (note that  with a little effort even "Types" can be 
> removed),
> so maybe I can add those essentials to my code,
> or even might switch to traits ;-)
>
>
>    Names  = [ 'For All Signals', 'AutoScale', 'Upper Value', 'Lower Value' 
> ]
>    Values = [  False,             True,        200,           20 ]
>    Types  = [  bool,              bool ]
>    OK, Values = MultiLineDialog ( Names, Values, Types,
>                                   'Set Border Values',
>                                   width = 70 )
>

No object oriented programming. I don't believe you can do complexe
codebases without OOP. Yes you can fight to avoid it, but you are doing
yourself more harm than good. And besides, it is not that hard.

In addition you don't have any reactive programming: the code above
cannot be interactive. This is what I call a "visual script". Going from
program-driven logics, where the user is presented sequentially a set of
dialogs, to user-driven logics, where the user (or an experiment) keeps
interacting with the program, will require a paradigm shift. I believe
that Traits will make this paradigm shifte easier than any alternative. I
also believe your second best bet is PyQt. But Traits has a nice
model/view separation in which you can get the reactive programming
without the GUI event-loop, and that's really nice.

In short, yes you do have to learn things, but you won't get an
interactive program for free, sorry.

Gaël


More information about the SciPy-user mailing list