开发者

IronPython bug related to long boolean expressions?

There seems to be something funny going on here. Using IronPython 2.6.2 for .NET 4.0, I get the following behaviour. The simplest case is as follows:

  1. I start the interactive shell
  2. I type the following line 5 times

    False or False or False or False or False or False or \
    
  3. I then end it with the following line

    False or False or False or False or False or False
    

As I am typing this, the process has clocked up 30 CPU minutes on a fairly good desktop and still not returned.

开发者_运维百科If I reduce step 2 by 1 i.e. have the line 4 times, then it returns in about a minute or two.

If I reduce step 2 by 2 ie. have the line 3 times, then it returns in about a second or so.

So what is happening, and why?

Of course, the real world example that caused me to isolate this is much more complex and not quite as frivolous looking.

Thanks Akil


I'd suggest opening a bug on CodePlex. What's happening here is that IronPython's OrExpression AST node is attempting to discover it's type. To do that it looks at the left hand type and the right hand type. If they're the same OrExpression will produce an expression of the type on the left hand side - which is checked again. That 2nd call is mostly what causes this to grow out of proportion. Simply changing OrExpression.cs from:

return _left.Type == _right.Type ? _left.Type : typeof(object);

to:

Type lType = _left.Type;
return lType == _right.Type ? lType : typeof(object);

fixes the problem.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜