473,406 Members | 2,378 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Multiple Inheritance __slots__ problem

Hello,

Can anyone tell why am I getting this error and how to work around this
problem.
class Klass(object): .... __slots__ = ( 'x' )
.... class Klass1(object): .... __slots__ = ( 'y' )
.... class Klass(Klass, Klass1):

.... __slots__ = ( 'z' )
....
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
TypeError: multiple bases have instance lay-out conflict

I need to define slots in these classes and also need to inherit them in
Derived class.

Nitin
Jul 18 '05 #1
1 2371
Nitin Shukla <ni*********@infotech.stph.net> wrote:
Hello,

Can anyone tell why am I getting this error and how to work around this
problem.
class Klass(object): ... __slots__ = ( 'x' )
... class Klass1(object): ... __slots__ = ( 'y' )
... class Klass(Klass, Klass1):
... __slots__ = ( 'z' )
...
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
TypeError: multiple bases have instance lay-out conflict


You're getting this error because there is no way to merge the layout of
those slots.
I need to define slots in these classes and also need to inherit them in
Derived class.


You never NEED to define slots anywhere: it's just a memory
optimization, that's all there is to it -- you're saving the size of a
dict per instance, a few tens of bytes per instance. Just remove the
slots all around: how many millions of instances of these classes do you
have alive at the same time? Identify the leaf class which has the many
millions of instances and reinstate slots there, only, if you really
truly can't spare the RAM.
Alex
Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: flori | last post by:
i try to greate somthing like this class ca(object): __slots__ = ("a",) class cb(ca): __slots__ = ("a","b") class cc(ca): __slots__ = ("a","c") class cd(cb,cc): __slots__ = ("a","b","c","d") ...
7
by: Porky Pig Jr | last post by:
Hello, I"m still learning Python, but going through the Ch 5 OOP of Nutshell book. There is discussion on __slots__, and my understanding from reading this section is that if I have a class...
0
by: Jonathan Brandmeyer | last post by:
I am attempting to create a class that inherits from a PyGTK class and a Boost.Python-based class. When the interpreter executes code like: class Myclass( gtk.some_class, my_boost_python_class):...
20
by: km | last post by:
Hi all, In the following code why am i not able to access class A's object attribute - 'a' ? I wishto extent class D with all the attributes of its base classes. how do i do that ? thanks in...
22
by: Matthew Louden | last post by:
I want to know why C# doesnt support multiple inheritance? But why we can inherit multiple interfaces instead? I know this is the rule, but I dont understand why. Can anyone give me some concrete...
5
by: jm.suresh | last post by:
Hi all, .... __slots__ = .... .... __slots__ = .... .... __slots__ = .... Traceback (most recent call last): File "<stdin>", line 1, in <module>
7
by: Adam Nielsen | last post by:
Hi everyone, I'm having some trouble getting the correct chain of constructors to be called when creating an object at the bottom of a hierarchy. Have a look at the code below - the inheritance...
47
by: Larry Smith | last post by:
I just read a blurb in MSDN under the C++ "ref" keyword which states that: "Under the CLR object model, only public single inheritance is supported". Does this mean that no .NET class can ever...
27
by: Licheng Fang | last post by:
Python is supposed to be readable, but after programming in Python for a while I find my Python programs can be more obfuscated than their C/C ++ counterparts sometimes. Part of the reason is that...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.