[Joshua Bronson]
> Raymond, do you think there might be any future in including a built-
> in bidict data structure in Python?

I don't think so.  There are several forces working against it:

* the recipe is new, so it hasn't had a chance to mature
  or to gain a fan club.

* there are many approaches to the solving the problem and
  there is no reason to assume this one is the best.

* it extends the language with arcane syntax tricks instead of
  using the language as designed by Guido.  That makes it harder
  to learn and remember.

* we've already got one (actually two).  The two dictionary approach
  uses plain python, requires no new learning, and is more flexible.
  Also, sqlite3 provides another way to use multiple lookups to a
  single record.  The database approach is much more general
  (extending to trijections, allowing multiple sort orders,
  providing persistence, etc).

* the semantics of a bijection aren't obvious:

     b['x'] = 'ex'      # first record:  ('x', 'ex')
     b['y'] = 'why'     # second record: ('y', 'why')
     b[:'why'] = 'x'    # do two records collapse into one? is there
an error?

* the proposed syntax doesn't address the issue covered in my previous
post.
  Since bijections are symmetrical, they do not have an obvious
direction
  (which is the primary key, the husband or the wife?).  The syntax
needs to
  allow user names to make it clear which is being accessed:

     marriages.h2w['john'] = 'amy'
     marriages.w2h['amy'] = 'john'

  Contrast this with:

     marriages['jordan'] = 'taylor'    # are you sure you got the
order correct?
     marriages[:'taylor'] = 'jordan'   # this is easy to get backwards


Raymond

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to