Re: [Python-Dev] Inconsistent behaviour in import/zipimport hooks

2005-11-14 Thread Ulrich Berning
Mark Hammond schrieb: release. The main reason why I changed the import behavior was pythonservice.exe from the win32 extensions. pythonservice.exe imports the module that contains the service class, but because pythonservice.exe doesn't run in optimized mode, it will only import a .py or a .pyc

Re: [Python-Dev] Inconsistent behaviour in import/zipimport hooks

2005-11-14 Thread Ulrich Berning
Guido van Rossum schrieb: On 11/11/05, Ulrich Berning [EMAIL PROTECTED] wrote: For instance, nobody would give the output of a C compiler a different extension when different compiler flags are used. But the usage is completely different. With C you explicitly manage when compilation

Re: [Python-Dev] Inconsistent behaviour in import/zipimport hooks

2005-11-12 Thread Mark Hammond
release. The main reason why I changed the import behavior was pythonservice.exe from the win32 extensions. pythonservice.exe imports the module that contains the service class, but because pythonservice.exe doesn't run in optimized mode, it will only import a .py or a .pyc file, not a .pyo

Re: [Python-Dev] Inconsistent behaviour in import/zipimport hooks

2005-11-11 Thread Ulrich Berning
Phillip J. Eby schrieb: At 04:33 PM 11/9/2005 -0800, Guido van Rossum wrote: On 11/9/05, Phillip J. Eby [EMAIL PROTECTED] wrote: By the way, while we're on this subject, can we make the optimization options be part of the compile() interface? Right now the distutils has to actually

Re: [Python-Dev] Inconsistent behaviour in import/zipimport hooks

2005-11-11 Thread Guido van Rossum
On 11/11/05, Ulrich Berning [EMAIL PROTECTED] wrote: Guido, if it was intentional to separate slightly different generated bytecode into different files and if you have good reasons for doing this, why have I never seen a .pyoo file :-) Because -OO was an afterthought and not implemented by

Re: [Python-Dev] Inconsistent behaviour in import/zipimport hooks

2005-11-10 Thread Nick Coghlan
Paul Moore wrote: On 11/9/05, Bob Ippolito [EMAIL PROTECTED] wrote: On Nov 9, 2005, at 1:48 PM, Thomas Heller wrote: Bob Ippolito [EMAIL PROTECTED] writes: On Nov 9, 2005, at 1:22 PM, Bill Janssen wrote: It's a shame that 1) there's no equivalent of java -jar, i.e., python -z FILE.ZIP,

Re: [Python-Dev] Inconsistent behaviour in import/zipimport hooks

2005-11-10 Thread Nick Coghlan
Nick Coghlan wrote: Please consider looking at and commenting on PEP 328 - I got zero feedback when I wrote it, and basically assumed no-one else was bothered by the -m switch's fairly significant limitations (it went in close to the first Python 2.4 alpha release, so we wanted to keep it

Re: [Python-Dev] Inconsistent behaviour in import/zipimport hooks

2005-11-10 Thread Paul Moore
On 11/10/05, Nick Coghlan [EMAIL PROTECTED] wrote: Paul Moore wrote: On 11/9/05, Bob Ippolito [EMAIL PROTECTED] wrote: On Nov 9, 2005, at 1:48 PM, Thomas Heller wrote: Bob Ippolito [EMAIL PROTECTED] writes: On Nov 9, 2005, at 1:22 PM, Bill Janssen wrote: It's a shame that 1)

Re: [Python-Dev] Inconsistent behaviour in import/zipimport hooks

2005-11-10 Thread Phillip J. Eby
At 04:33 PM 11/9/2005 -0800, Guido van Rossum wrote: On 11/9/05, Phillip J. Eby [EMAIL PROTECTED] wrote: By the way, while we're on this subject, can we make the optimization options be part of the compile() interface? Right now the distutils has to actually exec another Python process

Re: [Python-Dev] Inconsistent behaviour in import/zipimport hooks

2005-11-10 Thread Guido van Rossum
On 11/10/05, Phillip J. Eby [EMAIL PROTECTED] wrote: At 04:33 PM 11/9/2005 -0800, Guido van Rossum wrote: On 11/9/05, Phillip J. Eby [EMAIL PROTECTED] wrote: By the way, while we're on this subject, can we make the optimization options be part of the compile() interface? Right now the

Re: [Python-Dev] Inconsistent behaviour in import/zipimport hooks

2005-11-09 Thread Osvaldo Santana
On 11/9/05, Guido van Rossum [EMAIL PROTECTED] wrote: You didn't show us what's in the zip file. Can you show a zipinfo output? $ zipinfo modules.zip Archive: modules.zip 426 bytes 2 files -rw-r--r-- 2.3 unx 109 bx defN 31-Oct-05 14:49 module_o.pyo -rw-r--r-- 2.3 unx 109 bx

Re: [Python-Dev] Inconsistent behaviour in import/zipimport hooks

2005-11-09 Thread Guido van Rossum
Maybe it makes more sense to deprecate .pyo altogether and instead have a post-load optimizer optimize .pyc files according to the current optimization settings? Unless others are interested in this nothing will happen. I've never heard of a third party making their code available only as .pyo,

Re: [Python-Dev] Inconsistent behaviour in import/zipimport hooks

2005-11-09 Thread Nicola Larosa
Maybe it makes more sense to deprecate .pyo altogether and instead have a post-load optimizer optimize .pyc files according to the current optimization settings? That would not be enough, because it would leave the docstrings in the .pyc files. Unless others are interested in this nothing

Re: [Python-Dev] Inconsistent behaviour in import/zipimport hooks

2005-11-09 Thread Osvaldo Santana
On 11/9/05, Guido van Rossum [EMAIL PROTECTED] wrote: Maybe it makes more sense to deprecate .pyo altogether and instead have a post-load optimizer optimize .pyc files according to the current optimization settings? I agree with this idea, but we've to think about docstrings (like Nicola said

Re: [Python-Dev] Inconsistent behaviour in import/zipimport hooks

2005-11-09 Thread Guido van Rossum
On 11/9/05, Osvaldo Santana [EMAIL PROTECTED] wrote: I've noticed this inconsistency when we stop to use zipimport in our Python For Maemo distribution. We've decided to stop using zipimport because the device (Nokia 770) uses a compressed filesystem. I won't comment further on the brainstorm

Re: [Python-Dev] Inconsistent behaviour in import/zipimport hooks

2005-11-09 Thread Phillip J. Eby
At 11:32 AM 11/9/2005 -0800, Guido van Rossum wrote: On 11/9/05, Osvaldo Santana [EMAIL PROTECTED] wrote: I've noticed this inconsistency when we stop to use zipimport in our Python For Maemo distribution. We've decided to stop using zipimport because the device (Nokia 770) uses a compressed

Re: [Python-Dev] Inconsistent behaviour in import/zipimport hooks

2005-11-09 Thread Gustavo Sverzut Barbieri
On 11/9/05, Guido van Rossum [EMAIL PROTECTED] wrote: On 11/9/05, Osvaldo Santana [EMAIL PROTECTED] wrote: I've noticed this inconsistency when we stop to use zipimport in our Python For Maemo distribution. We've decided to stop using zipimport because the device (Nokia 770) uses a

Re: [Python-Dev] Inconsistent behaviour in import/zipimport hooks

2005-11-09 Thread Bill Janssen
It's a shame that 1) there's no equivalent of java -jar, i.e., python -z FILE.ZIP, and 2) the use of zipfiles is so poorly documented. Bill ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev

Re: [Python-Dev] Inconsistent behaviour in import/zipimport hooks

2005-11-09 Thread Bob Ippolito
On Nov 9, 2005, at 1:22 PM, Bill Janssen wrote: It's a shame that 1) there's no equivalent of java -jar, i.e., python -z FILE.ZIP, and This should work on a few platforms: env PYTHONPATH=FILE.zip python -m some_module_in_the_zip -bob ___

Re: [Python-Dev] Inconsistent behaviour in import/zipimport hooks

2005-11-09 Thread Thomas Heller
Bob Ippolito [EMAIL PROTECTED] writes: On Nov 9, 2005, at 1:22 PM, Bill Janssen wrote: It's a shame that 1) there's no equivalent of java -jar, i.e., python -z FILE.ZIP, and This should work on a few platforms: env PYTHONPATH=FILE.zip python -m some_module_in_the_zip It should, yes -

Re: [Python-Dev] Inconsistent behaviour in import/zipimport hooks

2005-11-09 Thread Bob Ippolito
On Nov 9, 2005, at 1:48 PM, Thomas Heller wrote: Bob Ippolito [EMAIL PROTECTED] writes: On Nov 9, 2005, at 1:22 PM, Bill Janssen wrote: It's a shame that 1) there's no equivalent of java -jar, i.e., python -z FILE.ZIP, and This should work on a few platforms: env PYTHONPATH=FILE.zip

Re: [Python-Dev] Inconsistent behaviour in import/zipimport hooks

2005-11-09 Thread Nick Coghlan
Bob Ippolito wrote: On Nov 9, 2005, at 1:22 PM, Bill Janssen wrote: It's a shame that 1) there's no equivalent of java -jar, i.e., python -z FILE.ZIP, and This should work on a few platforms: env PYTHONPATH=FILE.zip python -m some_module_in_the_zip Really? I wrote the '-m' code, and

Re: [Python-Dev] Inconsistent behaviour in import/zipimport hooks

2005-11-09 Thread Paul Moore
On 11/9/05, Bob Ippolito [EMAIL PROTECTED] wrote: On Nov 9, 2005, at 1:48 PM, Thomas Heller wrote: Bob Ippolito [EMAIL PROTECTED] writes: On Nov 9, 2005, at 1:22 PM, Bill Janssen wrote: It's a shame that 1) there's no equivalent of java -jar, i.e., python -z FILE.ZIP, and

Re: [Python-Dev] Inconsistent behaviour in import/zipimport hooks

2005-11-09 Thread Brett Cannon
On 11/9/05, Guido van Rossum [EMAIL PROTECTED] wrote: Maybe it makes more sense to deprecate .pyo altogether and instead have a post-load optimizer optimize .pyc files according to the current optimization settings? But I thought part of the point of .pyo files was that they left out

Re: [Python-Dev] Inconsistent behaviour in import/zipimport hooks

2005-11-09 Thread James Y Knight
On Nov 9, 2005, at 6:05 PM, Brett Cannon wrote: I would have no issue with removing .pyo files and have .pyc files just be as optimized as they the current settings are and leave it at that. Could have some metadata listing what optimizations occurred, but do we really need to have a

Re: [Python-Dev] Inconsistent behaviour in import/zipimport hooks

2005-11-09 Thread Guido van Rossum
On 11/9/05, Brett Cannon [EMAIL PROTECTED] wrote: On 11/9/05, Guido van Rossum [EMAIL PROTECTED] wrote: Maybe it makes more sense to deprecate .pyo altogether and instead have a post-load optimizer optimize .pyc files according to the current optimization settings? But I thought part of

Re: [Python-Dev] Inconsistent behaviour in import/zipimport hooks

2005-11-09 Thread Brett Cannon
On 11/9/05, Guido van Rossum [EMAIL PROTECTED] wrote: On 11/9/05, Brett Cannon [EMAIL PROTECTED] wrote: Plus I wouldn't be surprised if we started to move away from bytecode optimization and instead tried to do more AST transformations which would remove possible post-load optimizations.

Re: [Python-Dev] Inconsistent behaviour in import/zipimport hooks

2005-11-09 Thread Phillip J. Eby
At 03:25 PM 11/9/2005 -0800, Guido van Rossum wrote: The only solutions I can think of that use a single file actually *increase* the file size by having unoptimized and optimized code side-by-side, or some way to quickly skip the assertions -- the -OO option is a special case that probably needs

Re: [Python-Dev] Inconsistent behaviour in import/zipimport hooks

2005-11-09 Thread Guido van Rossum
On 11/9/05, Phillip J. Eby [EMAIL PROTECTED] wrote: At 03:25 PM 11/9/2005 -0800, Guido van Rossum wrote: The only solutions I can think of that use a single file actually *increase* the file size by having unoptimized and optimized code side-by-side, or some way to quickly skip the assertions

Re: [Python-Dev] Inconsistent behaviour in import/zipimport hooks

2005-11-09 Thread Guido van Rossum
[Guido] However, this would be a major pain for the standard library and other shared code -- there it's really nice to have a cache for each of the optimization levels since usually regular users can't write the .py[co] files there, meaning very slow always-recompilation if the standard

Re: [Python-Dev] Inconsistent behaviour in import/zipimport hooks

2005-11-09 Thread Brett Cannon
On 11/9/05, Guido van Rossum [EMAIL PROTECTED] wrote: [Guido] However, this would be a major pain for the standard library and other shared code -- there it's really nice to have a cache for each of the optimization levels since usually regular users can't write the .py[co] files

Re: [Python-Dev] Inconsistent behaviour in import/zipimport hooks

2005-11-09 Thread Guido van Rossum
I like Phillip's suggestion -- no new opcode, just a conditional jump that can be easily optimized out. Huh? But Phillip is suggesting a new opcode that is essentially the same as my proposal but naming it differently and saying the bytecode should get changed directly instead of having

Re: [Python-Dev] Inconsistent behaviour in import/zipimport hooks

2005-11-09 Thread Brett Cannon
On 11/9/05, Guido van Rossum [EMAIL PROTECTED] wrote: I like Phillip's suggestion -- no new opcode, just a conditional jump that can be easily optimized out. Huh? But Phillip is suggesting a new opcode that is essentially the same as my proposal but naming it differently and saying

Re: [Python-Dev] Inconsistent behaviour in import/zipimport hooks

2005-11-09 Thread Guido van Rossum
On 11/9/05, Brett Cannon [EMAIL PROTECTED] wrote: On 11/9/05, Guido van Rossum [EMAIL PROTECTED] wrote: I like Phillip's suggestion -- no new opcode, just a conditional jump that can be easily optimized out. Huh? But Phillip is suggesting a new opcode that is essentially the

Re: [Python-Dev] Inconsistent behaviour in import/zipimport hooks

2005-11-09 Thread Bill Janssen
This should work on a few platforms: env PYTHONPATH=FILE.zip python -m some_module_in_the_zip Yeah, that's not bad, but I hate setting PYTHONPATH. I was thinking more along the line of python -z ZIPFILE where python would look at the ZIPFILE to see if there's a top-level module called

Re: [Python-Dev] Inconsistent behaviour in import/zipimport hooks

2005-11-08 Thread Guido van Rossum
You didn't show us what's in the zip file. Can you show a zipinfo output? My intention with import was always that without -O, *.pyo files are entirely ignored; and with -O, *.pyc files are entirely ignored. It sounds like you're saying that you want to change this so that .pyc and .pyo are