Bryan Olson 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.
>>>
>>> Due to the number of checks perfromed by the script on the text files,
>>> (over 500), there are quite a few 'if' statements in the script, (over
>>> 1150).  It seems that it is at the point that when I add any additional
>>> 'if' statements the script will not run.  No error is produced - it
>>> just returns to the python prompt much the same as when a successful
>>> 'Check Module' command is selected.  If I delete some other 'if'
>>> statements the new ones work so it appears that it has hit a limit on
>>> the number of 'if' statements.  This has stunted any further checks for
>>> the script to make on the text files.
>>>
>>> Hs anyone ever run into this sort of thing?
>>
>>
>>
>> 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.

I tried that code. It runs fine.

However, the following gives a SystemError with only 2500 elif's.

#!/usr/bin/env python
lines = [ 'n = -1','m = 0','if n < 0:','   m = 2*n',]
for i in range(2500):
     lines.append('elif n == %i:' % i)
     lines.append('    m = 2*n')
prog = '\n'.join(lines)
progfile = file('if.py','w')
progfile.writelines(prog)
progfile.close()
exec prog

Traceback (most recent call last):
   File "iftest.py", line 10, in ?
     exec prog
SystemError: com_backpatch: offset too large

I tried this with Python 2.3.3 and 2.3.4 (Linux) and both fail.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to