Hi Bart,

On Fri, 2011-01-21 at 18:10 -0800, Bart Smaalders wrote:
> http://cr.opensolaris.org/~barts/17757/
> 
>      13054 solver could emit a directed error message for over-revved 
> incorporated pkgs
>      17757 pkg solver internationalizes its trim db strings too early, 
> reducing performance

Just another comment on 17757, the thousands of unique strings mentioned
in the description are virtually impossible to translate of course.

On the other hand, if the worry here is the overhead caused by repeated
calls to _() then creating a bunch of constants and looking up the
translations once, on module import would be good. So,

#!/usr/bin/python
import gettext
gettext.install("/")

msg = {}
HOVERCRAFT_CONTENTS = "My %(hovercraft)s is full of %(eels)s"
msg[HOVERCRAFT_CONTENTS] = _(HOVERCRAFT_CONTENTS)
.
.

in which case, the code:

for val in range(0, 1000000):
    len(msg[HOVERCRAFT_CONTENTS])

works out 2 seconds faster on my machine than using
"len(_(HOVERCRAFT_CONTENTS))" on the last line.

Eventually, we'd format msg[HOVERCRAFT_CONTENTS] with a dictionary
containing values for "hovercraft" and "eels" when you got to print it,
as I'd suggested the bug report.

If use of constants makes the code slightly less readable, we could
expand to msg["My %(hovercraft)s is full of %(eels)s"]

I've not reviewed the rest of the code yet.

        cheers,
                        tim


_______________________________________________
pkg-discuss mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/pkg-discuss

Reply via email to