Difference between revisions of "Python"
From Healthcare Robotics Wiki
(→math, science, numerical, etc.) |
(→efficiency) |
||
| Line 13: | Line 13: | ||
== efficiency == | == efficiency == | ||
| + | When you need buffering of some sort for logging/writing data, if speed is important use the deque() data structure instead of lists (see: http://pythonorific.org/blog/blog-2009-09-24-0109.html) | ||
| + | This can be done by the following commands: | ||
| + | from collections import deque | ||
| + | buffer = deque() | ||
| + | |||
| + | buffer.append(x) | ||
| + | #or | ||
| + | buffer.appendleft(x) #to append an item=x to the deque on one end or the other | ||
| + | |||
| + | buffer.pop() | ||
| + | #or | ||
| + | buffer.popleft() #to pop the item from one end or the other | ||
Revision as of 14:16, 29 October 2009
learning python
- python for programmers
- guido's guide (http://docs.python.org/tut/)
- dive into python (book) (http://www.diveintopython.org/toc/index.html)
- quick reference (http://rgruet.free.fr/PQR25/PQR2.5.html)
- ipython (http://ipython.scipy.org/moin/)
math, science, numerical, etc.
- numpy (http://numpy.scipy.org/)
- scipy (http://scipy.org/)
- matplotlib (http://matplotlib.sourceforge.net/): in ipython shell
- mayavi (http://code.enthought.com/projects/mayavi/)
efficiency
When you need buffering of some sort for logging/writing data, if speed is important use the deque() data structure instead of lists (see: http://pythonorific.org/blog/blog-2009-09-24-0109.html) This can be done by the following commands:
from collections import deque
buffer = deque()
buffer.append(x)
#or
buffer.appendleft(x) #to append an item=x to the deque on one end or the other
buffer.pop()
#or
buffer.popleft() #to pop the item from one end or the other