On Nov 22, 2007 6:23 AM, Georg Brandl <[EMAIL PROTECTED]> wrote: > Guido van Rossum schrieb: > > I was looking at this too. The root cause of the test failure is that > > unicode_translate() calls PyDict_Copy() on its argument dict, and then > > modifies the copy to add extra keys. This seems awfully expensive. > > Isn't there another way? (I'm imagining that often the dict is rather > > large and the string rather short...) > > I added that dict copy in order to make translate() more robust. > It used to directly call PyUnicode_TranslateCharmap which simply > ignores invalid entries and only accepts ordinals as keys, while > allowing ordinals and strings as values. Both these points made > its behavior confusing enough to warrant some extra comfort.
Can I ask you to think of a solution that is less expensive though? A common pattern is to call translate() on lots of different strings with the same argument dict; each call will cause the dict to be copied and manipulated, which (for short strings) is likely to cost much more than the actual translation. That's a hefty price to pay for some extra comfort. -- --Guido van Rossum (home page: http://www.python.org/~guido/) _______________________________________________ Python-3000-checkins mailing list [email protected] http://mail.python.org/mailman/listinfo/python-3000-checkins
