Using python for _large_ projects like IDE

Eric Brunel eric.brunel at
Mon Jan 19 10:29:57 CET 2004

Sridhar R wrote:
> Hi,
> I am a little experienced python programmer (2 months).  I am somewhat
> experienced in C/C++.  I am planning (now in design stage) to write an
> IDE in python.  The IDE will not be a simple one.  I had an idea of
> writing the IDE in C/C++, as it is a big project, bcoz of the
> following
> 1. if python is used, then the memory required for running the IDE
> will be high.

It's quite hard to tell, since I've never seen anybody writing a significant 
application *both* in C/C++ and Python to compare their memory usage... I'd say 
memory usage depends a lot more on the design than on the language used. Python 
does introduce an extra cost in memory consumption, but the larger the 
application, the less you'll notice it.

> 2. if pure python is used, the IDE will be slower.

An application coded in Python will actually be slower than the same application 
coded in C/C++. I won't repeat what others have already said about what *looks* 
slow to a user.

> I'm not sure whether they are true.
> Then I thought of using python for 90% of the code and using C for
> other performance critical part.  But the problem is in identifying
> the performance critical code.  People suggest to start with pure
> python and then _recode_ the performance critical code after profiling
> the original code.  But I fear whether there will be a conflit in say
> data structures.  Not yet expert in extending/embedding python.

We did just that for quite a big application and it works like a charm: the 
critical code is usually one that does many calculations and it's usually quite 
easy to isolate this part in a module handling only base types. And even if it's 
not true, as somebody already said, it's easier to handle Python objects at C 
level that it may seem at first sight.

> Are there any ways to forsee the performance critical parts?

I really think you shouldn't care; remember, "premature optimization is the root 
of all evil" ;-)

> Also, any suggestions on reducing memory usage of big applications
> written in python?

Design them keeping this problem in mind if you really have to. But... 
"premature optimization ...". You'll always be able to make compromises on a 
well designed application afterwards to reduce memory usage; it's indeed a lot 
easier than to maintain an application originally badly designed for bad reasons 
(e.g. reduce memory consumption).

- Eric Brunel <eric dot brunel at pragmadev dot com> -
PragmaDev : Real Time Software Development Tools -

More information about the Python-list mailing list