troubleshooting Question

Speeding up Python Code

Avatar of tmonteit
tmonteitFlag for Afghanistan asked on
Editors IDEs
4 Comments1 Solution285 ViewsLast Modified:
I have some rather messy python code that does what it is supposed to but takes forever to run.

The code is often run as a script from the command line.  

The code does some batch xml processing and pushes  (sometimes) some data up through the google code API.

When I run the command, it takes about 15 seconds for the program to load before it even executes.  How can I make this all load faster?  

I tried eliminating some of the libraries and it seems to run much faster if I comment out the xml libraries, but then it doesn't do what I need.
import cgi
import os, sys
import base64 
import date, time, datetime
import getpass
import pdb
import pickle
import getopt
import sys
import commands
import os
import pdb
import re
import easygui
import feedparser
from optparse import OptionParser

# XML Parsing
from xml.etree.ElementTree import ElementTree, SubElement, dump
from xml.dom.minidom import parseString
from xml.sax import saxutils
import xml.dom.minidom
import xml.utils.iso8601
from xml.sax import saxutils

# Google G-data
import gdata.gauth
import gdata.contacts.client
import gdata.docs.client
from google.appengine.ext.remote_api import remote_api_stub 
from google.appengine.ext import db 
from google.appengine.api import users
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros