On Mon, May 6, 2013 at 4:27 PM, Michael Bayer <mike...@zzzcomputing.com> wrote:
> as for the __slots__ thing, that's a separate issue.    if your patch doesn't 
> break tests we can set that for 0.9 as well, I doubt anyone is subclassing 
> InstanceState, though I'd want to see what the speedup is with that.

About 15% on state creation (which can easily be a big chunk of any
bulk ORM operations):

>>> class InstanceState(object):
...    __slots__ = ('a','b','c','__dict__','__weakrefs__')
...    def __init__(self):
...        self.a = "a"
...        self.b = "b"
...        self.c = "c"
...
>>> class InstanceStateSlow(object):
...    def __init__(self):
...        self.a = "a"
...        self.b = "b"
...        self.c = "c"
...
>>> def test(which):
...    for i in xrange(10):
...       x = which()
...
>>> import timeit
>>> timeit.timeit(lambda : test(InstanceStateSlow))
8.486893892288208
>>> timeit.timeit(lambda : test(InstanceState))
7.358500003814697

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to