Saturday, June 16, 2007

Opera 9.2 is a pretty good browser

I've been trying Opera 9.2 for a week, and I'm pleased with it enough that it's going to continue to be my main browser. The main selling points for me are

  • MDI weirdness is mostly hidden now, I hated earlier Opera UIs
  • 20-30% less memory use; even after poking about in the guts of about:config to force FF's memory cache to the same 10MB that I gave Opera (which exposes this option right in the UI), Opera consistently uses less memory for the same workload. (Without adding this option to FF, it would max out around 400MB instead of 150MB.)
  • feels snappier; opera seems quicker to start rendering something useful on slow-loading sites like 1up.com, although total render time is about the same. It's also instantaneous to open a new tab, which consistently takes around 1s on FF after I've been using it a while. I open and close tabs frequently.
  • UI takes up less space: I know it's possible to re-skin FF, but I'd have to google it to find out how. Opera makes it easy. I'm using the Fresh skin for Opera which condenses the File menu and nav bar to about half as much height as FF uses.
  • built-in AutoFill, so I save even more space by not needing Google Toolbar
  • javascript/DOM support is finally close enough to FF that most sites don't have to specifically code for Opera. Heavy ajax use is an exception of course; I still have to use FF for Google Docs. (Gmail and Maps work fine though, probably due to some effort by Google.)
  • Download manager goes in another tab by default instead of a separate window. I didn't realize how much FF's behavior annoyed me before.

Downsides:

  • Occasional rendering problems, such as when customizing a laptop on hp.com. Blogger.com doesn't redirect to my dashboard when I'm already logged in to my google account.
  • Very very slow navigating large pages, such as a slashdot comment thread with 400 comments. Isearch is even slower on large pages and can lock up the UI for minutes if you invoke it injudiciously.
  • Sometimes ignores a site's instructions to not cache a dynamic page
  • hard to tell which tab is active in the default theme. (Fresh fixes this.)

Thursday, June 14, 2007

A workaround for the sys.excepthook bug

About two years ago I reported the bug sys.excepthook doesn't work in threads. Then just recently someone asked in #utahpython if I had a workaround. Here it is (also added as a comment to the bug report) -- all we do is monkeypatch Thread.run to run the excepthook manually if there is an uncaught exception:

def install_thread_excepthook():
    """
    Workaround for sys.excepthook thread bug
    (https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1230540&group_id=5470).
    Call once from __main__ before creating any threads.
    If using psyco, call psyco.cannotcompile(threading.Thread.run)
    since this replaces a new-style class method.
    """
    import sys, threading
    run_old = threading.Thread.run
    def run(*args, **kwargs):
        try:
            run_old(*args, **kwargs)
        except (KeyboardInterrupt, SystemExit):
            raise
        except:
            sys.excepthook(*sys.exc_info())
    threading.Thread.run = run