How big can a Python program be?

Ben Last ben at
Tue Aug 17 15:54:55 CEST 2004

Hmmm... are all the resulting code objects kept forever, or are those that
are no longer required subject to garbage collection?  If so, one could keep
feeding expressions, such as x+y for random values of x & t, to the
interpreter indefinitely :)  Or, slightly more seriously, if completed code
blocks are compiled to single code objects (as is done in a shell
environment based on and then executed, one could keep feeding
meaningful code segments to the interpreter indefinitely, as long as each is
complete unto itself.  Of course, each can process data "left" by the
preceding ones, since they all execute within the same namespace.


> -----Original Message-----
> From: at
> [ at]On Behalf Of
> Peter Hansen
> Sent: 17 August 2004 14:46
> To: python-list at
> Subject: Re: How big can a Python program be?
> Ben Last wrote:
> > Unless I've misremembered, the Python interpreter executes
> lines as they're
> > entered, whether read from a file or typed in (with the exception that
> > blocks of code made up of multiple lines are executed when the
> last line is
> > complete), so in theory, one could feed code to Python
> indefinitely and it'd
> > just keep going.
> You've misremembered.  Python actually *compiles* the code prior
> to executing it, turning it into bytecode.  That means there is
> definitely a limit on how much code can be handled, based if nothing
> else on the memory in your PC.
> -Peter
> --

More information about the Python-list mailing list