开发者

Loading Google App Engine app from one file for all the URLs or one file per URL for loading speed

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.开发者_如何学Goappengine.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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜