Tkinter special math chars

Jeff Epler jepler at unpythonic.net
Thu May 19 14:39:21 EDT 2005


On Thu, May 19, 2005 at 12:56:12PM -0500, phil wrote:
> Why is it so slow? (RH Linux, 2.4.20, 1.6Ghz AMD)
> 3/4 second slower to display widget w/unicode,
> even if I encode u'\u221e'

u'\u221e' vs u'\N{INFINITY}' should make no noticible run-time
difference--they both specify exactly the same string, and the decoding
takes place at the time the script or module is byte-compiled.

What Tk does at runtime is inspect a large number of fonts until it
finds one with the desired character---or all the fonts, if the
character doesn't exist.  Querying all the fonts on your
system can take quite a bit of time.  I believe that Tk caches this
information until program exit, or at least as long as the font is in
use, and characters that are nearby in their unicode values will be
resolved at the same time.

I'm not aware of a good explanation of the low-level font handling in
Tk; The information in the above paragraph was gleaned by reading the
source code (tkUnixFont.c and tkWinFont.c).

Jeff
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20050519/1af14da3/attachment.sig>


More information about the Python-list mailing list