2008/12/2 Matt Craighead <[EMAIL PROTECTED]>:
> Brett,
>
> Yes, I'm aware that pyc files can be decompiled -- but this does at least
> strip comments from the code, slightly speed up loading, and a few other
> minor things.

Any speedup in load time isn't going to help much since the code is
only loaded once at process start and then persists for life of
process. This isn't CGI, loading is not done on every request.

Thus, if load time is the only reason you are using .pyc files, I
wouldn't be bothering. You will get more from simply ensuring that
application code is preloaded at process start rather than mod_wsgi
default of lazy load on first request.

Doing preloading helps to ensure that you don't see slight pauses on
process reloads. If using daemon mode, you would though probably also
want to run 2 or more processes for this to be completely effective.

To ensure preloading occurs, use WSGIImportScript directive to point
at the WSGI script file.

> I guess the simplest workaround would be to create a 1-line file
> "csc_manager.wsgi" as follows?
>
> from csc_manager_wsgi import application

Yes, that will work. Just ensure that your real .py/.pyc files are not
in the same directory but are instead somewhere outside of directories
exposed via Apache, with Python module search path set to get them
from this alternate location. You don't want them in Apache document
directories because if you don't configure Apache right, you might
create situation where they can be downloaded by external people.

Also suggest reading:

  http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode

It talks more about how WSGI script file is treated in special ways.

Overall I would counsel against premature optimisations of the sort
you are trying to do, especially if you don't have evidence or
supporting documentation that suggests it is worthwhile.

Alone using .pyc files, also warn against using WSGIPythonOptimize and
.pyo files. The justification isn't really there for using it.

Graham

> On Mon, Dec 1, 2008 at 3:24 PM, Brett Hoerner <[EMAIL PROTECTED]>
> wrote:
>>
>> On Mon, Dec 1, 2008 at 2:17 PM, Matt Craighead
>> <[EMAIL PROTECTED]> wrote:
>> > Works fine if I give it the .py file, but I prefer to ship my software
>> > as
>> > .pyc files rather than .py files.  Is there a way to tell mod_wsgi to
>> > load a
>> > precompiled .pyc script?
>>
>> The docs say,
>>
>> "In all ways that the WSGIScriptAlias can be used, the target script
>> is not required to have any specific extension type and in particular
>> it is not necessary to use a '.py' extension just because it contains
>> Python code. Because the target script is not treated exactly like a
>> traditional Python module, if an extension is used, it is recommended
>> that '.wsgi' be used rather than '.py'."
>>
>> Especially note the last sentence.  The wsgi script isn't a normal
>> Python file, really.  Is there any reason you want it to be a pyc?
>> (You're aware that pyc files can be easily decompiled - right?)
>>
>> Brett
>>
>> 512-772-1834
>>
>> >>
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"modwsgi" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/modwsgi?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to