Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #111728
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Max size of Python source code and compiled equivalent |
| Date | 2016-07-21 20:17 +0200 |
| Organization | None |
| Message-ID | <mailman.37.1469125203.22221.python-list@python.org> (permalink) |
| References | <1469119864.416096.672987297.69184C7E@webmail.messagingengine.com> <nmr3o9$gin$1@ger.gmane.org> |
Malcolm Greene wrote:
> We're writing a DSL parser that generates Python code. While the size of
> our generated code will be small (< 32K), I wanted to re-assure the rest
> of our team that there are no reasonable code size boundaries that we
> need to be concerned about. I've searched for Python documentation that
> covers max Python source (*.py) and compiled file (*.pyc) sizes without
> success. Any tips on where to look for this information?
>
> Background: Python 3.5.1 on Linux.
I don't know if/where this is documented, but there are structural limits:
>>> def nested(N):
... return "".join(" " * i + "if 1:\n" for i in range(N)) + " " * N +
"print('hi')"
...
>>> print(nested(3))
if 1:
if 1:
if 1:
print('hi')
>>> exec(nested(99))
hi
>>> exec(nested(100))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 101
print('hi')
^
IndentationError: too many levels of indentation
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Max size of Python source code and compiled equivalent Peter Otten <__peter__@web.de> - 2016-07-21 20:17 +0200
csiph-web