*1*- Should we always use GridTableBase<Weiterleitungshinweis a virtual table for *wx.grid
*objects (because it makes the grid faster)?
only if the Gird is large -- there are some use-cases with smaller data
sets where it's fine to use the regular version. But I'd say of the dataset
is arbitrarily large, then yes.
*2*- Is it OK to use a dictionary to keep the grid data of virtual table as
below:
self.data = {(0,0):"cell_content_1", (0,1):"cell_content_2", ...}
Or do you recommend a list, tuple or a set instead of a dictonary? Which
one is fastest?
well, I think a list of lists is the most natural, and will be very
efficient.
A dict like that would make sense if the data in the grid is sparse -- i.e.
lots of empty cells, then you wouldn't need to store anything for the empty
ones. But if there are not very many empty cells, then a list of lists maps
well to the rectangular nature of the grid.
I wouldn't use tuples, as they are immutable, you'd need to re-create them
if anything changed. It might be OK if it's read only data, though.
as for fastest, a lis tof lists should be a bit fast, but I doubt you'd
notice -- both are order 1 access.
now that I think about it -- if you are removing rows or columns frequently
a dict might be a better choice for performance, but it would be a bit
uglier for code.
Another option -- I'd consider a numpy array -- they can be true 2-d arrays
which maps better to the grid data model. They can hold either homogenous
data types (e.g. all floats), or python objects, much like a list. Numpy
arrays would let you more naturally access the data by either rows or
columns.
Sorry -- that was a bit rambling -- but when it comes down to it the short
answer is "it depends"
-CHB
Christopher Barker, PhD
Python Language Consulting
- Teaching
- Scientific Software Development
- Desktop GUI and Web Development
- wxPython, numpy, scipy, Cython
···
On Sat, Jan 18, 2014 at 1:52 PM, steve <oslocourse@gmail.com> wrote: