Home > Programming, Python > Speed in Python

Speed in Python

Some notes about optimizing the running time issue in python.


 out = "<html>" + head + prologue + query + tail + "</html>"

Instead, use

 out = "<html>%s%s%s%s</html>" % (head, prologue, query, tail)

Even better, for readability (this has nothing to do with efficiency other than yours as a programmer), use dictionary substitution:

 out = "<html>%(head)s%(prologue)s%(query)s%(tail)s</html>" % locals()


– http://stackoverflow.com/questions/788084/how-can-i-optimize-this-python-code

-Some fun python module:

pycallgraph is a Python module that creates call graphs for Python programs.
– profile
output a table that contains running time information for the modules.

NetworkX —  tools for analyzing network data–period
PyMC          — Bayesian/MCMC modelers
SimPy         — “Simulation in Python”,  tool set for designing experiments
SymPy        — library for symbolic mathematics.
html5lib    — web data parser
Pycluster   — clustering algorithms (efficient implementations of hierarchical and k-means clustering)
cjson           — fast JSON(JavaScript Object Notation) encoder/decoder for Python.
Pyevolve    — A complete pure python genetic algorithm framework.
MySQL for Python
RPy2           — simple Python interface for R, able to execute any R function from within a Python script.
PulP             — Optimization
Categories: Programming, Python
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: