[C++-sig] Re: C++/Boost vs. Python object memory footprint

David Abrahams dave at boost-consulting.com
Thu Dec 12 18:52:26 CET 2002


David Abrahams <dave at boost-consulting.com> writes:

> Stephen Davies <chalky at ieee.org> writes:
>
> I'll run a quick test now to see when __dict__ gets filled in.

Good news.

I checked, and instance dicts are only created "on demand" in
Boost.Python extension instances.

    >>> a = A()  # some extension class A, no instance dict
    >>> a.x      # Attribute lookup fails, still no instance dict
    Traceback ...

    >>> a.y = 1  # y is a C++ data member, still no instance dict
    >>> a.x = 1  # creates an instance dict
    >>> z = A()
    >>> z.__dict__  # also creates an instance dict

HTH,
-- 
                       David Abrahams
   dave at boost-consulting.com * http://www.boost-consulting.com
Boost support, enhancements, training, and commercial distribution





More information about the Cplusplus-sig mailing list