Changes between Version 14 and Version 15 of PsycoMiddleware


Ignore:
Timestamp:
07/10/2007 05:02:27 PM (8 years ago)
Author:
Ludvig Ericson <ludvig.ericson@…>
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • PsycoMiddleware

    v14 v15  
    33class PsycoMiddleware(object):
    44    """
    5     This middleware enables the psyco extension module which can massively
     5    Enables the psyco extension module which can massively
    66    speed up the execution of any Python code.
    77    """
     8
    89    def process_request(self, request):
    910        try:
     
    8889See http://psyco.sourceforge.net/psycoguide/node14.html for more information
    8990
    90 Known problems:
     91Instead of throwing an exception when the platform is wrong, one could just not start psyco.
     92
     93{{{
     94import psyco
     95import platform
     96import re
     97
     98if platform.architecture()[0] == '32bit':
     99    psyco.cannotcompile(re.compile)  # re.compile doesn't benefit from psyco
     100    psyco.profile()  # psyco.profile seems like the most sane choice.
     101
     102# The middleware class definition is just here so django doesn't whine.
     103# Note also that we placed this class outside the if so that
     104# the middleware can be used without effect.
     105class PsycoMiddleware(object):
     106    """
     107    Enables the psyco extension module which can massively
     108    speed up the execution of any Python code.
     109    """
     110    pass
     111}}}
     112
     113= Known problems =
    91114Psyco is great and you should look into it, but sometimes it can create weird problems (in conjunction with other software) that may be hard to debug. Please remember to turn it off when you have strange / not so obvious problems.
Back to Top