On Fri, 17 Dec 2004 13:24:43 -0600, Mike Meyer <[EMAIL PROTECTED]> wrote:
>Jeff Shannon <[EMAIL PROTECTED]> writes:
> 
> > Sion Arrowsmith wrote:
> > Additionally, as I understand it UserList and UserDict are implemented
> > entirely in Python, which means that there can be significant
> > performance differences as well.
> 
> Actually, UserList and UserDict are just wrappers around the builtin
> types. So the performance hit is one Python function call - pretty
> much neglible. But new code should still subclass the builtins.
  Only tangentially related, but I'll bring it up anyway: method calls 
are more expensive than function calls:

    [EMAIL PROTECTED]:~$ timeit -s "def foo(): pass" "foo()"
    1000000 loops, best of 3: 0.382 usec per loop
    [EMAIL PROTECTED]:~$ timeit -s "class Foo:
        def foo(self): pass
    f = Foo()" "f.foo()"
    1000000 loops, best of 3: 0.611 usec per loop
    [EMAIL PROTECTED]:~$ 

  This is due to the attribute lookup as well as the creation and 
destruction of a bound method object for each call.

  Jp
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to