On Mon, Aug 24, 2009 at 12:41 AM, Simon King <simon.k...@nuigalway.ie>wrote:
> > Hi Minh, > > On 24 Aug., 02:10, Minh Nguyen <nguyenmi...@gmail.com> wrote: > [...] > > > Since I am not an experienced programmer: Are there reasons to not use > > > a dictionary for those kind of things? > > > > A good point: searching through a dictionary is essentially constant > time. > > > > A bad point: can't assume that each key/value pair in a dictionary > > would always be ordered in exactly the same way. This assumption was > > uncovered during the development of Sage 4.1.1 when a doctest failed. > > The cause of the failure: the doctest assumed that printing the > > key/value pairs of a dictionary would always result in exactly the > > same arrangement of key/value pairs. Bad assumption there. > > But you couldn't use the attribute "._properties" in doc tests anyway, > because AFAIK rings are cdef classes, so, you can't access the > attributes on a python level. Yes you can, if you declare them "cdef public _properties". But the dictionaries-in-doctests issue is something we have contended with for years and their a standard solution. When you write a doctest that involves printing out d, instead print out say: list(sorted(list(d))) or something like that. -- William --~--~---------~--~----~------------~-------~--~----~ To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---