Python Distilled

S

Simon Wittber

I want to build a Python2.5 interpreter for an embedded system. I only
have 4MB of RAM to play with, so I want to really minimise the python
binary.

Things I can think of removing safely are:
- Unicode
- Long numbers
- Complex number
- Compiler / Parser
- Thread support
- OS specific stuff

I'd also like to remove any deprecated or stuff which is left in for
backwards functionality (eg Classic classes).

Google tells me that people have done this before, back in Python1.5.2
days. Has anyone tried to do this recently with a more modern Python?

-Sw.
 
M

Marc 'BlackJack' Rintsch

Simon Wittber said:
I'd also like to remove any deprecated or stuff which is left in for
backwards functionality (eg Classic classes).

Classic classes are still needed for exceptions:
.... pass
....Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: exceptions must be classes, instances, or strings (deprecated),
not type

Ciao,
Marc 'BlackJack' Rintsch
 
G

Georg Brandl

Marc said:
Classic classes are still needed for exceptions:

... pass
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: exceptions must be classes, instances, or strings (deprecated),
not type

The error is a bit misleading, since in Python 2.5 all exceptions are new-style,
but new exception classes must be derived from an existing one.
Classic classes, their instances and strings are only allowed for backwards
compatibility.

Georg
 
J

Jorge Godoy

Marc 'BlackJack' Rintsch said:
Classic classes are still needed for exceptions:

... pass
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: exceptions must be classes, instances, or strings (deprecated),
not type

On the other hand...
.... pass
.... Traceback (most recent call last):


This also has the advantage to let it explicit in the code that E is an
exception.
 
P

Paul McGuire

Marc 'BlackJack' Rintsch said:
Classic classes are still needed for exceptions:

... pass
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: exceptions must be classes, instances, or strings (deprecated),
not type

Ciao,
Marc 'BlackJack' Rintsch

I thought exceptions were converted to new-style classes for Py2.5
(http://docs.python.org/whatsnew/pep-352.html). I've not upgraded yet, so
cannot easily test this - under what version of Python was your posted code
run?

-- Paul
 
T

The Eternal Squire

Try also Diet Python on SourceForge.

It's the first step toward a shrunken Python for embedded Win32
systems.

Cheers,

The Eternal Squire
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top