473,385 Members | 1,478 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,385 software developers and data experts.

Inheritance in nested classes

I'm experimenting with using Python for a small web interface, using
Mark Hammond's nice win32 extensions.

I use a small class hierarchy which uses inheritance and nested classes.

Here are a small extract of the code:

class page:

def __init__(self):
self.head=[]

def __str__(self):
...

class simple_tag:
...

class p(simple_tag):
...

class table:
...

class row:
...

class data:
...
...
Will this type of code perform noticable slower than unnested classes?

I'm using the Active Server Pages integration in the win32 extensions,
does anyone have good/bad experiences using this interface?

Thanks.

/Martin

Nov 22 '05 #1
3 2050
Martin Skou wrote:
I'm experimenting with using Python for a small web interface, using
Mark Hammond's nice win32 extensions.

I use a small class hierarchy which uses inheritance and nested classes.

Here are a small extract of the code:

class page:

def __init__(self):
self.head=[]

def __str__(self):
...

class simple_tag:
...

class p(simple_tag):
...

class table:
...

class row:
...

class data:
...
...
Will this type of code perform noticable slower than unnested classes?


I'm not aware that there is much runtime penalty here - a quick test
reveals that:

import time

class Foo:
def __init__(self, baz):
self.baz = baz

def unnested():
o = Foo(10)

def nested():
class Foo:
def __init__(self, baz):
self.baz = baz

then = time.time()
for i in xrange(100000):
unnested()
print time.time() - then

then = time.time()
for i in xrange(100000):
nested()
print time.time() - then
Yields

0.839588165283
0.817638158798

for me.

But I hope you are aware that nested classes aren't quite the same as
they are in java, are you?

Regards,

Diez
Nov 22 '05 #2
"Diez B. Roggisch" <de***@nospam.web.de> wrote:
But I hope you are aware that nested classes aren't quite the same as
they are in java, are you?


Actually they are more like java's static inner classes. If you want to
simulate non-static inner classes in python, you may check the recipe
here:
http://aspn.activestate.com/ASPN/Coo.../Recipe/409366.

George

Nov 22 '05 #3
"I'm using the Active Server Pages integration in the win32 extensions,

does anyone have good/bad experiences using this interface?"

What is it you are trying to do?
I'm using python2.4 with win32 and IIS/python ASP and find it ok. There
were at some point some session overlappings but I'm not sure if it was
the asp interface or my ajax code?

Anyway I have someting you may find usefull in doing asp with python at
http://www.emilas.com/pwh/
and this has an ORM that has an html form generator if I guess your
intention of generating html using python. The generator there is not
general but rather oriented towords databases tables and views.

Nov 22 '05 #4

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

Similar topics

10
by: Paul Morrow | last post by:
I'm hoping that someone can explain why I get the following exception. When I execute the code... ###################################### class Parent(object): class Foo(object): baz = 'hello...
15
by: Bob | last post by:
I need to apply a border to a table's columns, but not to the columns of tables nested within (I realize nested tables are bad form, it's a client request). I can't control what goes inside this...
4
by: KInd | last post by:
Hello All, When is nested class more preferable that Inheritance ? I think with proper inheritance and friend class concept we can get the same flexibility as nested classes Any comments .. Best...
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...
7
by: Ryan Shaw | last post by:
I’m having a small problem with inheritance with a hierarchy of classes The example is Class Class Private m_classB as Class Class Class End Clas End Clas
4
by: news.microsoft.com | last post by:
Hello, I've got a design problem that I can't figure out. I need to override a static method which happens to be referenced by methods inside nested classes. In the sample below, in the call...
16
by: devicerandom | last post by:
Hi, I am currently using the Cmd module for a mixed cli+gui application. I am starting to refactor my code and it would be highly desirable if many commands could be built as simple plugins. ...
49
by: Ben Voigt [C++ MVP] | last post by:
I'm trying to construct a compelling example of the need for a language feature, with full support for generics, to introduce all static members and nested classes of another type into the current...
21
by: raylopez99 | last post by:
Well, contrary to the implication in my 2000 textbook on C# (public beta version), C# does allow multiple inheritance, so long as it's serially chained as follows: class derived02 : derived01 {...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.