I did a little more 'thorough' testing on the differences between dict.get(key) and dict[key]. I tested for both keys that do and do not exist, and I seem to have different results than what I did last time =(
It seems dict[key] is about twice as fast as dict.get(key) when the key does exist in the dict. On the other hand, dict[key] + exception handling is twice as slow as dict.get(key) when key is not in dict. Here's the extra twist: checking if the key is in dict and then getting the appropriate value is only slightly slower than simply table[key]. This is something like:
if key in dict:or, more elegantly:
value = dict[key]
else:
value = None
value = None if key not in dict else dict[key]
This method is fractionally slower than dict[key] when key is in the table, but it's considerably faster when key is not in the table. Also, this method is consistantly faster than dict.get(key) in both cases.
The script can be found [here]
The output for 100,000 iterations of each case can be found [here]
The output shows the name of each test case followed by the commands executed in the test. Total runtime for each follow each.
I may have done the cases a little naively, but I still think it shows some powerful differences.
Posted by: Chris Waters
| @ October 30, 2007 7:43:51 PM CST ( ) |
Installing GLEW
Download the GLEW source from [here]
Run the following command in the glew folder:
> GLEW_DEST=/usr/local sudo make install
Installing GLEWpy
Download the GLEWpy source from [here]
Replace the setup.py in the glewpy folder with the modified setup.py from [here]
Run the following command in the glewpy folder:
> sudo python setup.py install
Posted by: Chris Waters
| @ October 30, 2007 7:28:12 PM CST ( ) |
This is useful for 'faster' logins, or programs that use SSH and don't support a login (ex: SCPlugin SVN GUI for OSX)
On local machine, create and upload the key: > ssh-keygen -t dsa
** overwrite if you need to **
** enter empty passphrase (is this safe?) **
> scp ~/.ssh/id_dsa.pub username@server
Login to remote server and do: > cat id_dsa.pub >> .ssh/authorized_keys
> rm id_dsa.pub
I did this a while back, but never took notes. *sigh*
Posted by: Chris Waters
| @ October 29, 2007 6:01:03 PM CST ( ) |
def GetWXBitmap(myImage):
image = apply(wx.EmptyImage, myImage.size)
image.SetData(myImage.convert("RGB").tostring())
# if the image has an alpha channel,
# you can set it with this line:
myImage = myImage.convert("RGBA")
image.SetAlphaData(myImage.tostring()[3::4] )
return image.ConvertToBitmap()
FROM:
http://wiki.wxpython.org/WorkingWithImages#head-7aa43a4a1e066fd28640ce86066ba0617afe2a8b
Using wx.StaticBitmap (widget on the window to show the bitmap):
http://wiki.wxpython.org/wxStaticBitmap?highlight=%28Bitmap%29
Posted by: Chris Waters
| @ September 17, 2007 4:17:27 PM CDT ( ) |
If you're familiar with wxPython, you may also be familiar with the many ways you can do/import the same exact thing... or are they the same?
When porting <s>wxWindows</s> wxWidgets to Python, there ended up being class name conversions like "wxPanel" to "wx.Panel". At the same time (!!), you can use "wxPython.wxPanel". This wouldn't be so bad if the wxPython Wiki stuck with -one- of these. There is a Style Guide on the wiki, but that doesn't seem to be followed very well. =(
The wxOGL page is very guilty of inconsistencies.
Posted by: Chris Waters
| @ November 9, 2006 3:10:02 PM CST ( ) |
Chi, E. H. 2000. A Taxonomy of Visualization Techniques Using the Data State Reference Model. In Proceedings of the IEEE Symposium on information Vizualization 2000 (October 09 - 10, 2000). INFOVIS. IEEE Computer Society, Washington, DC, 69. http://portal.acm.org/citation.cfm?id=857691
Posted by: Chris Waters
| @ September 6, 2006 3:31:06 PM CDT ( ) |
Pfitzner, D., Hobbs, V., and Powers, D. 2003. A unified taxonomic framework for information visualization. In Proceedings of the Asia-Pacific Symposium on information Visualisation - Volume 24 (Adelaide, Australia). T. Pattison and B. Thomas, Eds. ACM International Conference Proceeding Series, vol. 142. Australian Computer Society, Darlinghurst, Australia, 57-66. http://portal.acm.org/citation.cfm?id=857087
Posted by: Chris Waters
| @ September 6, 2006 3:30:36 PM CDT ( ) |
I've been working on developing a sort of 'taxonomy' to classify Information Visualizations. The taxonomy is a combination of visualization factors from Pfizner '03 [url] and Chi '00 [url]. The hope is to find similar characteristics between the different information visualizations.
Posted by: Chris Waters
| @ September 6, 2006 3:25:24 PM CDT ( ) |
It's interesting how one 'small' change can affect speed so much. During this morning's internet downtime, I was poking through some Moire drawing code looking for places to possibly optimize performance. This led me to write a quick performance testing script with hotshot that tests the runtime differences between dict.get(key) and dict[key].
It turns out that the dict.get() method is exponentially (haha *poke* at a comment someone made) faster than the indexing (?) method. I'm assuming this is due to the fact that the latter raises a key error if the key is not found. This may actually be something worth keeping in mind from now on.
By the way, The Python Challenge has me in its grasp again.
Posted by: Chris Waters
| @ February 17, 2006 12:34:16 PM CST ( ) |
I've been skimming through the Python Coroutine PEP [link], and it's making my brain hurt. I'm loving the way this is going to work, but the first example (thumbnail generator) just blows my mind.
Things like this make me want to get more into reading these Python devs' blogs.
Posted by: Chris Waters
| @ February 16, 2006 2:28:36 PM CST ( ) |
I've finished installing a LaTeX parser for the Vislab notes wiki [url].
Now it is possible to create typeset "text" (in the form of images) using LaTeX on the wiki. The parser information page [url] has more information.
Note: both the normal and inline parsers are installed.
Posted by: Chris Waters
| @ September 19, 2005 2:42:57 PM CDT ( ) |
Schussman, G., Ma, K.L. 2002. Scalable Self-Orienting Surfaces: A Compact, Texture-Enhanced Representation for Interactive Visualization Of 3D Vector Fields. In Proceedings of the 10th Pacific Conference on Computer Graphics and Applications. http://graphics.idav.ucdavis.edu/publications/print_pub?pub_id=774
Posted by: Chris Waters
| @ August 24, 2005 1:57:57 PM CDT ( ) |
Stompel, A., Lum, E., and Ma, K.L. 2002. Feature-Enhanced Visualization of Multidimensional, Multivariate Volume Data Using Non-photorealistic Rendering Techniques. In Proceedings of the 10th Pacific Conference on Computer Graphics and Applications. http://graphics.idav.ucdavis.edu/publications/print_pub?pub_id=775
Posted by: Chris Waters
| @ August 24, 2005 1:57:39 PM CDT ( ) |
Zöckler, M., Stalling, D., and Hege, H. 1996. Interactive visualization of 3D-vector fields using illuminated stream lines. In Proceedings of the 7th Conference on Visualization '96 (San Francisco, California, United States, October 28 - 29, 1996). R. Yagel and G. M. Nielson, Eds. IEEE Visualization. IEEE Computer Society Press, Los Alamitos, CA, 107-ff.
Posted by: Chris Waters
| @ August 24, 2005 1:57:22 PM CDT ( ) |
Gooch, A., Gooch, B., Shirley, P., and Cohen, E. 1998. A non-photorealistic lighting model for automatic technical illustration. In Proceedings of the 25th Annual Conference on Computer Graphics and interactive Techniques SIGGRAPH '98. ACM Press, New York, NY, 447-452. DOI= http://doi.acm.org/10.1145/280814.280950
Posted by: Chris Waters
| @ August 24, 2005 1:56:59 PM CDT ( ) |
|
|

