views:

45

answers:

1

I have a small web app running on AppEngine and have all my URL processing in one file and the other processing done in another file that is imported at the top of the main python.

e.g.

import wsgiref.handlers
from wsgiref.handlers import format_date_time
import logging
import os
import cgi
import datetime
from time import mktime

#Google Libraries
from django.utils import simplejson
from google.appengine.ext import webapp
from google.appengine.ext import db
from google.appengine.ext.db import Error
from google.appengine.ext.webapp import template
from google.appengine.api import memcache

#Model Libraries
from Models import *
from Render import *
from Sound import *


#Few classes to handle the URLS

and since these are at the top of the file they are loaded first when any of the URLS are hit. I have done it this way because the some URLs need to have the same libraries.

My question is, if I carried on building my app this way, would it be better split the URLs into their own files with the libraries they need so that slowly but sure the libraries are moved into memory as more URLs are requested or would it be better to do everything in one big hit when any of the URLS is hit

p.s. I appreciate that in a real world this probably not an issue but I am just curious

+1  A: 

There's no need to split your handlers into separate files. However, if you're importing something that's going to use a lot of CPU when it's imported and won't be used by many of your handlers, it's best to move your imports inside your handler classes so you can take advantage of lazy loading.

Wooble
Thanks for your answer :)
AutomatedTester