473,762 Members | 6,570 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Shrinky-dink Python (also, non-Unicode Python build is broken)

I'm an indie shareware Windows game developer. In indie shareware
game development, download size is terribly important; conventional
wisdom holds that--even today--your download should be 5MB or less.

I'd like to use Python in my games. However, python24.dll is 1.86MB,
and zips down to 877k. I can't afford to devote 1/6 of my download
to just the scripting interpreter; I've got music, and textures, and
my own crappy code to ship.

Following a friend's suggestion, as an experiment I downloaded the
Python 2.4.2 source, then set about stripping out everything I could.
I removed:
* Unicode support, including the CJK codecs
* All doc strings
* *Every* module written in C
Now when I build, python24.dll is 570k, and zips down to about 260k.
But I learned some things on the way.
First and foremost: turning off Py_USING_UNICOD E *breaks the build*
on Windows. The following list of breakages were all fixed with
judicious applications of #ifdef Py_USING_UNICOD E:
* The implementation of "multi-byte codecs" (CJK codecs) implicitly
assumes that they can use all the Unicode facilities. So all the
files in "Modules/cjkcodecs" fail to build.
* Obviously, the Unicode string object depends on Unicode support,
so Objects/unicode* doesn't build.
* There are several spots in the code that need to handle Unicode
strings in some slightly special way, and assume Unicode is turned
on. E.g.:
* Modules/posixmodule.c, posix__getfullp athname(), line 1745
* same file, posix_open(), starting on line 5201
* Objects/fileobject.c, open_the_file() , starting on line 158
* _winreg.c, Py2Reg(), starting on lines 724 and 777

In addition, there was one slightly more complicated problem: _winreg.c
assumes it should call PyUnicode_Decod eMBCS() to turn strings pulled
from the registry into Unicode strings. I'm not sure what the correct
thing to do here is; I went with changing the calls from
PyUnicode_Decod eMBCS() to PyString_FromSt ringAndSize() for non-Unicode
builds.

Of course, it's not the most important thing in the world--after all,
I'm the first person to even *notice*, right? But it seems a shame
that
one can break the build so easily. If it pleases the stewards of
Python, I would be happy to submit patches that fix the non-"using
Unicode" build.
Second of all, the dumb-as-a-bag-of-rocks Windows linker (at least
the one used by VC++ under MSVS .Net 2003) *links in unused static
symbols*. If I want to excise the code for a module, it is not
sufficient to comment-out the relevant _inittab line in config.c.
Nor does it help if I comment out the "extern" prototype for the
init function. As far as I can tell, the only way to *really* get
rid of a module, including all its static functions and static data,
is to actually *remove all the code* (with comments, or #if, or
whatnot). What a nosebleed, huh?

So in order to build my *really* minimal python24.dll, I have to hack
up the source something fierce. It would be pleasant if the Python
source code provided an easy facility for turning off modules at
compile-time. I would be happy to propose something / write a PEP
/ submit patches to do such a thing, if there is a chance that such
a thing could make it into the official Python source. However, I
realize that this has terribly limited appeal; that, and the fact
that Python releases are infrequent, makes me think it's not a
terrible hardship if I had to re-hack up each new Python release
by hand.
Whatcha think, froods?
/larry/

Jan 16 '06
10 2220
Are you willing to monitor and fix new Py_USING_UNICOD E issues or
are you proposing just to produce a patch now and then expect
contributors to maintain this feature?


Neither, I suppose, or perhaps both. I am proposing to produce a patch
now which fixes the non-Unicode build under Windows. However, I don't
expect anything out of other contributors, and I don't set Python
contribution policy. (Obviously the stewards of the Python tree don't
care whether contributions break the non-Unicode build. But that's a
fine policy; after all, they've already got enough to do, and in any
case I'm the first person to even notice.) If this patch is accepted,
and some future contribution breaks the non-Unicode build again, and I
discover the breakage, I might very well create a second patch to
re-fix it.

Since I'm seemingly the only person who cares about non-Unicode builds
on Windows, I suggest this approach would work just fine.
/larry/

Jan 17 '06 #11

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

Similar topics

0
1822
by: Irmen de Jong | last post by:
QOTW: "Giving full access rights to a secretary or new programmer ought to insure an occasional random file deletion." -- Raymond Hettinger "I always use join, but that's probably because that method is more likely to run code that I once wrote. Never trust code written by a man who uses defines to create his own C syntax." -- Fredrik Lundh Discussion ----------
0
1445
by: Irmen de Jong | last post by:
QOTW: "The best use for a bug report on comp.lang.python is as an object lesson for your grandchildren: 40 years from now you can search the archives for it, and tell the little darlings 'see? if I had only put that on SourceForge instead, the bug would have been fixed by now'." -- Tim Peters "I thought we made dictionaries out of trees... Are you trying to reverse entropy? " -- Bob Gailer
0
1277
by: Brent Turner | last post by:
Under python 2.2 I was able to create a COM object in an exe much of the same way that I could from py source... meaning that I was able to register the com server and create an instance using the current process (exe/source) as the com server. Now, in python 2.3 when I try to create the COM instance from the exe, it starts up a new process and fails (b/c my exe does not support the command line parameters) The Source below is what...
0
2239
by: Emile van Sebille | last post by:
QOTW (in the OS agnostic category): "There is a (very popular) Python package out there which exposes the win32 api. I'm not sure what it's called. (win32api? pythonwin? win32all?)" -- Francis Avila QOTW (in the popular vote category): "So far, python has been the easiest language to learn I've ever come across. I tried learning perl, and it was a disaster.... Too convoluted. Python is a breath of fresh air. Also, the docs and...
0
1193
by: Cameron Laird | last post by:
QOTW: "What is so nice about Python is that there are so many places on the user/scripter/programmer/computer-scientist spectrum where you can be and find Python to be a useful tool. This makes it very easy to build good collaborations between domain experts and 'real programmers' where both sides can use the same language and neither feels constrained or overwhelmed." - Roy Smith "In this setting I'd say that Java is a win, though I...
0
1535
by: Simon Brunning | last post by:
QOTW: "" - John Machin, snipping a section of Perl code. "What sort of programmer are you? If it works on your computer, it's done, ship it!" - Grant Edwards Guido invites us to comment on PEP 343. This Python Enhancement Proposal includes a 'with' statement, allowing you simply and reliably wrap a block of code with entry and exit code, in which resources can be acquired and released. It also proposes enhancements
0
1118
by: Simon Brunning | last post by:
QOTW: "Python is more concerned with making it easy to write good programs than difficult to write bad ones." - Steve Holden "Scientists build so that they can learn. Programmers and engineers learn so that they can build." - Magnus Lycka "It happens that old Java programmers make one module per class when they start using Python. That's more or less equivalent of never using more than 8.3 characters in filenames in modern operating...
2
1470
by: Toon Knapen | last post by:
I'm trying to build the svn-trunk version of python on a Solaris box. However I do not have a python installed yet and apparantly the build of python requires a python to be accessible (as also annotated in the Makefile generated during the ./configure). How can I solve this situation? Thanks, toon
0
1275
by: Jack Diederich | last post by:
QOTW: "being able to cook an egg" - Guido Van Rossum in response to the question, "What do you think is the most important skill every programmer should posses?" "I am asking for your forgiveness" - an open letter to Guido by someone who took the "D" in "BDFL" too literally. Parsing a Grammar. Several solid tools are suggested. http://groups.google.com/group/comp.lang.python/browse_thread/thread/ea9736e13bd20fe2
0
9378
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9989
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8814
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6640
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5268
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3914
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3510
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2788
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.