Avatar of tmonteit
tmonteit
Flag for Afghanistan asked on

Speeding up Python Code

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

Open in new window

Editors IDEs

Avatar of undefined
Last Comment
HonorGod

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
HonorGod

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
tmonteit

ASKER
the first thing the code does is open an xml file and parse for data.  if that helps any.  So xml is right away.
tmonteit

ASKER
the first thing the code does is open an xml file and parse for data.  if that helps any.  So xml is right away.
HonorGod

Thanks for the grade & points.

Good luck & have a great day.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck