How big can a Python program be?

Ben Last ben at benlast.com
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 cmd.py) 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.

b

> -----Original Message-----
> From: python-list-bounces+ben=benlast.com at python.org
> [mailto:python-list-bounces+ben=benlast.com at python.org]On Behalf Of
> Peter Hansen
> Sent: 17 August 2004 14:46
> To: python-list at python.org
> 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
> --
> http://mail.python.org/mailman/listinfo/python-list




More information about the Python-list mailing list