Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

.py to .pyc

96 views
Skip to first unread message

Colin J. Williams

unread,
May 13, 2012, 5:27:14 PM5/13/12
to
Is there some way to ensure that a .pyc file is produced when executing
a .py file?

It seems that for small files the .pyc file is not produced.

Colin W.

Irmen de Jong

unread,
May 13, 2012, 5:36:02 PM5/13/12
to
All modules no matter how small produce a .pyc file *when they are imported*. If you
start a module directly though, no .pyc is produced. (Notice that Python 3 puts the pyc
files in a subdirectory.)

Why do you care anyway? Pyc files are an implementation detail.

Irmen

Colin J. Williams

unread,
May 13, 2012, 5:43:12 PM5/13/12
to
Is there some way to ensure that a .pyc file is produced when executing
a .py file?

It seems that for small files the .pyc file is not produced.

Colin W.
PLEASE IGNORE - I was in the wrong directory.

Colin W.

Steven D'Aprano

unread,
May 13, 2012, 8:03:54 PM5/13/12
to
On Sun, 13 May 2012 23:36:02 +0200, Irmen de Jong wrote:

> On 13-5-2012 23:27, Colin J. Williams wrote:
>> Is there some way to ensure that a .pyc file is produced when executing
>> a .py file?
>>
>> It seems that for small files the .pyc file is not produced.
>>
>> Colin W.
>
> All modules no matter how small produce a .pyc file *when they are
> imported*. If you start a module directly though, no .pyc is produced.
> (Notice that Python 3 puts the pyc files in a subdirectory.)

That's only the case for Python 3.2 and higher, not 3.1.

You can also use this:

python -m compileall

to produce .pyc files without waiting for them to be imported.



--
Steven
Message has been deleted

Colin J. Williams

unread,
May 19, 2012, 7:54:18 AM5/19/12
to
On 18/05/2012 7:20 PM, Tony the Tiger wrote:
> On Sun, 13 May 2012 23:36:02 +0200, Irmen de Jong wrote:
>
>> Why do you care anyway?
>
> Wanna hide his code...?
>
> /Grrr
Curiosity. Perhaps there are stack-based processors out there which
could use the .pyc code more directly.

Colin W.

88888 Dihedral

unread,
May 20, 2012, 9:55:10 AM5/20/12
to
On Saturday, May 19, 2012 7:54:18 PM UTC+8, Colin J. Williams wrote:
> On 18/05/2012 7:20 PM, Tony the Tiger wrote:
> > On Sun, 13 May 2012 23:36:02 +0200, Irmen de Jong wrote:
> >
> >> Why do you care anyway?
> >
> > Wanna hide his code...?
> >
> > /Grrr
> Curiosity. Perhaps there are st ack-based processors out there which
> could use the .pyc code more directly.
>
> Colin W.

Uhn, don't forget the famous Z-80, and forth CPU which were stack based.
But I am trained in the register based C as my favorite low level language
higher than any assembly.

0 new messages