2010-02-04 54 views
0

我有一個運行在AppEngine上的小型網絡應用程序,並將所有URL處理在一個文件中,其他處理在另一個文件中完成導入在主python的頂部。從一個文件加載所有URL或一個文件加載Google App Engine應用程序加載速度

例如

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 

由於這些文件位於文件的頂部,所以當任何URLS被命中時,它們首先被加載。我這樣做是因爲一些URL需要有相同的庫。

我的問題是,如果我繼續以這種方式構建我的應用程序,是否更好地將URL拆分爲它們自己的文件和它們需要的庫,以便緩慢但確定將庫移動到內存中,因爲需要更多的URL或者當任何URLS被擊中時,做一切事情會更好嗎?

ps我明白,在現實世界中,這可能不是問題,但我只是好奇

回答

1

有沒有必要將您的處理程序拆分爲單獨的文件。但是,如果您導入的東西在導入時會佔用大量CPU,並且不會被許多處理程序使用,則最好將您的導入內容移入處理程序類中,以便利用延遲加載。

+0

感謝您的回答:) – AutomatedTester 2010-02-11 12:34:03

相關問題