[IronPython] Differences between cpython and ironpython

Jörgen Stenarson jorgen.stenarson at bostream.nu
Wed Nov 15 21:15:58 CET 2006


Hi,

Sorry my announcement message on the ironpython pyreadline port got the 
wrong subject.

This mail contains the differences I found between cpython and 
ironpython when working on the pyreadline port.

1) import time is much higher in ironpython than cpython

2) Had to patch source to be able to replace readline function:

in PythonCommandLine.cs change class definition:
   class PythonCommandLine
to:
   public class PythonCommandLine

3) Defaultprompt, in cpython the prompt is printed by readline (it is 
passed as a parameter to readline).
    In ironpython the interpreter prints it before calling readline.


4) mode string for open: in cpython does not react to unknown characters 
like "rt"=="r"

5) It seems I'm unable to catch KeyboardInterrupts properly. It looks 
like the except logic is executed but the KeyboardInterrupt is reraised 
automatically.

6) rlcompleter had to be patched

line 85:
             self.namespace = __main__.__dict__
should read
             self.namespace = __main__.__dict__.copy()
I think it is related to the following difference in behaviour


C:\IronPython-1.0.1>ipy
IronPython 1.0 (1.0) on .NET 2.0.50727.42
Copyright (c) Microsoft Corporation. All rights reserved.
 >>> import __main__
 >>> w=10
 >>> for w in __main__.__dict__:
...      print w
...
[__name__, __main__]
Traceback (most recent call last):
   File , line 0, in <stdin>##105
   File mscorlib, line unknown, in MoveNext
   File mscorlib, line unknown, in ThrowInvalidOperationException
SystemError: Collection was modified; enumeration operation may not execute.
 >>>

compared to cpython:
C:\IronPython-1.0.1>python
Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)] on 
win32
Type "help", "copyright", "credits" or "license" for more information.
 >>> import __main__
 >>> w=10
 >>> for w in __main__.__dict__:
...     print w
...
quit
__builtins__
__file__
exit
w
__main__
__name__
__doc__
 >>>






More information about the Ironpython-users mailing list