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

Python Distilled

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.

Nov 6 '06 #1
8 1095
In <11**********************@m73g2000cwd.googlegroups .com>, Simon Wittber
wrote:
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:
>>class E(object):
.... pass
....
>>raise E
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
Nov 6 '06 #2
Marc 'BlackJack' Rintsch wrote:
In <11**********************@m73g2000cwd.googlegroups .com>, Simon Wittber
wrote:
>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:
>>>class E(object):
... pass
...
>>>raise E
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
Nov 6 '06 #3
Marc 'BlackJack' Rintsch <bj****@gmx.netwrites:
In <11**********************@m73g2000cwd.googlegroups .com>, Simon Wittber
wrote:
>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:
>>>class E(object):
... pass
...
>>>raise E
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...
>>import exceptions
class E(exceptions.Exception):
.... pass
....
>>raise E
Traceback (most recent call last):
File "<stdin>", line 1, in ?
__main__.E
>>>

This also has the advantage to let it explicit in the code that E is an
exception.
--
Jorge Godoy <jg****@gmail.com>
Nov 6 '06 #4
"Marc 'BlackJack' Rintsch" <bj****@gmx.netwrote in message
news:pa****************************@gmx.net...
In <11**********************@m73g2000cwd.googlegroups .com>, Simon Wittber
wrote:
>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:
>>>class E(object):
... pass
...
>>>raise E
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
Nov 6 '06 #5
Paul McGuire wrote:
"Marc 'BlackJack' Rintsch" <bj****@gmx.netwrote in message
news:pa****************************@gmx.net...
>In <11**********************@m73g2000cwd.googlegroups .com>, Simon Wittber
wrote:
>>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:
>>>>class E(object):
... pass
...
>>>>raise E
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).
Yes, they were. Still, you can't raise instance of arbitrary new-style classes
as exceptions, and you will never be able to. In Py3k, only instances of
"BaseException" subclasses will be raisable.

Georg
Nov 6 '06 #6
Simon Wittber wrote:
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.
[snip]
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?
http://www.python.org/dev/summary/20...rinking-python

STeVe
Nov 6 '06 #7
http://www.python.org/dev/summary/20...rinking-python

Excellent, just what I was hoping for. Thanks!

-Sw.

Nov 7 '06 #8
Try also Diet Python on SourceForge.

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

Cheers,

The Eternal Squire
Simon Wittber wrote:
http://www.python.org/dev/summary/20...rinking-python

Excellent, just what I was hoping for. Thanks!

-Sw.
Nov 7 '06 #9

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

Similar topics

220
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have...
699
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
1
by: Emile van Sebille | last post by:
QOTW: "If we get 2.3.3c1 out in early December, we could release 2.3.3 final before the end of the year, and start 2004 with a 100% bug-free codebase <wink>." -- Tim Peters "cjOr proWe vbCould...
9
by: Adam Barr | last post by:
For a book I am working on, I have written a brief (9 page) summary of Python. The intent of this is that an experienced programmer who did not know Python would be able to get enough information...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.