So the main thing you want to do is the following:
(1) load some big data once
(2) do computations with it interactively (i.e. scripts use the newest version)
Right?
This is a job for the class constructor. The pattern below will let you load the data once and then modify it with scripts (or at the command line). All scripts will use the most updated version of the data.
Let me know if this helps.
Cheers,
Will
Write a script that loads the data. Save it as filename.py
Then, every time you want to use the data, you can "import filename".
The first time you call import, it will run the loading script. Every
other time you import, it will not run the loading script. If you
want to force a reload of the data, use "reload filename". Now, if
you want to modify the data in-place, without touching the saved data
file, you can simply overwrite/alter/modifiy/whatever to the data,
filename.x. When your script calls "import filename", nothing will
happen, and the modified x will be used. Also, if you want to spoof
data, you can write alternative fake_filename.py scripts, and "import
fake_filename as filename" to get the spoofed data (with, for example,
a small subset of the data for testing purposes).
Note that none of this is ipython-specific, and would work equally
well in python code as in the ipython shell.
Ethan
> --
> William GK Martin
> Graduate Student of Applied Mathematics
> Columbia University
>
> email: wgm...@columbia.edu
> phone: 503-332-7227
--
-------------------------------------------------------------------
Ethan Coon
DOE CSGF - Graduate Student
Dept. Applied Physics & Applied Mathematics
Columbia University
212-854-0415
http://www.ldeo.columbia.edu/~ecoon/
-------------------------------------------------------------------
I just tried out your way. Pretty nifty use namespaces.
The only limitation seems to be that this way will support only one copy of the data. Once reload is called the modified data is lost (unless it is manually saved). And, even if it is saved the scripts will only work on the one copy that is stored as 'filename.x'.
The main benefit of using classes would be the ability to make and modify multiple copies of the data. Each instance has its own data and methods that use that data.
Right?
cheers,
Will
--
William GK Martin
Graduate Student of Applied Mathematics
Columbia University
email: wgm...@columbia.edu
phone: 503-332-7227
But that's what you want for a large, single data set. If you wanted
multiple data sets, you'd do better with a class, like you said.
Ethan