[Tutor] .py vs .pyc
Could anyone tell me why I should use a .pyc file rather than a .py? After doing some research, I have found that a .py file is first precompiled and then run, while a .pyc file is already precompiled and is simply run. But unless I'm mistaken, it seems that a .pyc is no faster or better than a .py file. When should I use a .py, and when should I use a .pyc? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] .py vs .pyc
Then if I understand correctly, I work with .py files and (should) run them as .pyc files? On Thu, Apr 19, 2012 at 10:55 AM, Russel Winder rus...@winder.org.ukwrote: On Thu, 2012-04-19 at 10:47 -0400, Max S. wrote: Could anyone tell me why I should use a .pyc file rather than a .py? After doing some research, I have found that a .py file is first precompiled and then run, while a .pyc file is already precompiled and is simply run. But unless I'm mistaken, it seems that a .pyc is no faster or better than a .py file. When should I use a .py, and when should I use a .pyc? pyc files are just internal PVM files. Although they appear on the filestore visible to the programmer, just leave management of them to the PVM. Humans deal only with .py files -- or possibly pyx if you are using Cython. -- Russel. = Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.win...@ekiga.net 41 Buckmaster Roadm: +44 7770 465 077 xmpp: rus...@winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] .py vs .pyc
On Thu, 2012-04-19 at 10:47 -0400, Max S. wrote: Could anyone tell me why I should use a .pyc file rather than a .py? After doing some research, I have found that a .py file is first precompiled and then run, while a .pyc file is already precompiled and is simply run. But unless I'm mistaken, it seems that a .pyc is no faster or better than a .py file. When should I use a .py, and when should I use a .pyc? pyc files are just internal PVM files. Although they appear on the filestore visible to the programmer, just leave management of them to the PVM. Humans deal only with .py files -- or possibly pyx if you are using Cython. -- Russel. = Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.win...@ekiga.net 41 Buckmaster Roadm: +44 7770 465 077 xmpp: rus...@winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder signature.asc Description: This is a digitally signed message part ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] .py vs .pyc
On Thu, 2012-04-19 at 10:57 -0400, Max S. wrote: Then if I understand correctly, I work with .py files and (should) run them as .pyc files? No, you always run the py files, don't worry about the pyc files at all, the PVM will do what it does. -- Russel. = Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.win...@ekiga.net 41 Buckmaster Roadm: +44 7770 465 077 xmpp: rus...@winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder signature.asc Description: This is a digitally signed message part ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] .py vs .pyc
On 19/04/12 15:47, Max S. wrote: Could anyone tell me why I should use a .pyc file rather than a .py? You don't, python handles that for you. They only come into effect on import statement. When Python imports the module it will use the pyc if available (and more recent that the .py). Don't try to second guess this just let Python do what it does. After doing some research, I have found that a .py file is first precompiled and then run, while a .pyc file is already precompiled and is simply run. But unless I'm mistaken, it seems that a .pyc is no faster or better than a .py file. The pyc file will be imported faster because python will not need to do the initial precompile. Other than that small improvement it should make no difference. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor