Alan Morgan <[EMAIL PROTECTED]> wrote:
> In article <[EMAIL PROTECTED]>,
> Bryan Olson <[EMAIL PROTECTED]> wrote:
>>Alan Morgan wrote:
>>> slogging_away wrote:
>>>
>>>>Hi - I'm running Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310
>>>>32 bit (Intel)] on win32, and have a script that makes numerous checks
>>>>on text files, (configuration files), so discrepancies can be reported.
>>>>The script works fine but it appears that I may have hit a wall with
>>>>'if' statements.
>>>>
>>> I generated files with 10000, 25000, and 50000 simple if statements and ran
>>> them. 10000 was okay, 25000 gave a bizarre internal error, and 50000
>>> segfaulted
>>> and died. My system has plenty of memory and it isn't obvious to me why
>>> python
>>> should be so bothered about this. I'm not sure why I can have 10x the
>>> number of
>>> if statements that cause you trouble. There might be some overall
>>> limitation
>>> on the number of statements in a file.
>>
>>I made a script with 100,000 if's, (code below) and it appears
>>to work on a couple systems, including Python 2.4.2 on Win32-XP.
>>So at first cut, it doesn't seem to be just the if-count that
>>triggers the bug.
>
> Mine was a simple
>
> #!/usr/local/bin/python
>
> zot=24999
> if zot == 0:
> print "It's 0"
>
> if zot == 1:
> print "It's 1"
>
> ....
>
> if zot == 24999:
> print "It's 24999"
>
> generated (I'm ashamed to admit) by a perl script. Is there any good
> reason why it is failing? I'd prefer a "Too many silly walks in your
> program. Reduce!" to a crash. I could experiment with putting the
> matching 'if' at the beginning rather than at the end, but I'm not
> sure what that would tell me.
Here[1] it works with 400000 (with 500000 it starts swapping too much)
"if"-statements generated by
==========================================
#!/usr/bin/env python
print """#!/usr/bin/env python
zot=24999
"""
for i in range(0, 400000):
print """
if zot == %d:
print "It's %d"
"""%(i,i)
============================================
[1] Python 2.4.2 (#2, Sep 30 2005, 21:19:01)
[GCC 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu8)]
Florian
--
No no no! In maths things are usually named after Euler, or the first
person to discover them after Euler.
[Steven D'Aprano in <[EMAIL PROTECTED]>]
--
http://mail.python.org/mailman/listinfo/python-list