[IronPython] Comparing clr objects in lists

Dino Viehland dinov at exchange.microsoft.com
Tue Oct 3 19:51:56 CEST 2006

This is definitely a bug - I've opened CodePlex issue 3982 to track this (http://www.codeplex.com/WorkItem/View.aspx?ProjectName=IronPython&WorkItemId=3982).   Thanks for reporting it.  I suspect this is due to the fact that our enums don't implement compare, and we are doing a compare (and checking it's zero) instead of a simple equality check when comparing the lists.  Some interesting other data points are:

x = Color.Red
[x] == [x]

Prints True (because you're using the same boxed enum) and:

{Color.Red:Color.Red} == {Color.Red:Color.Red} also works (we're doing an equality check instead of a comparison).

Any input on how we should prioritize this?

-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Andrzej Krzywda
Sent: Tuesday, October 03, 2006 5:35 AM
To: Discussion of IronPython
Subject: [IronPython] Comparing clr objects in lists

Hello all,

We found an issue with comparing clr objects in lists.

IronPython 1.0.60816 on .NET 2.0.50727.42 Copyright (c) Microsoft Corporation. All rights reserved.
 >>> import clr
 >>> clr.AddReference('System.Drawing')
 >>> from System.Drawing import Color
 >>> Color.Red == Color.Red
 >>> (Color.Red) == (Color.Red)
 >>> [Color.Red] == [Color.Red]
 >>> [(Color.Red)] == [(Color.Red)]

The same kind of comparison will work with IronPython objects.

Andrzej Krzywda
users mailing list
users at lists.ironpython.com

More information about the Ironpython-users mailing list