[Issue 7515] The new std.string.translate is slow for ASCII text

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Mar 6 15:42:22 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=7515



--- Comment #4 from bearophile_hugs at eml.cc 2012-03-06 15:42:22 PST ---
(In reply to comment #3)

> It seems to me that the only reason that makeTrans exists in the first place
> rather than just putting it in translate is so that you can reuse the
> translation table. No one should be messing with it or passing anything else to
> that version of translate.

As several other string functions, the two functions we are talking about here
come from Python2:
http://docs.python.org/library/string.html#string-functions
http://docs.python.org/library/string.html#string.translate


The Python docs tell the size of the table too:

string.translate(s, table[, deletechars])
    Delete all characters from s that are in deletechars (if present), and then
translate the characters using table, which must be a 256-character string
giving the translation for each character value, indexed by its ordinal. If
table is None, then only the character deletion step is performed.


In Python some times I have built the translation table manually. If makeTrans
returns an opaque or privately defined struct this is not possible.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list