473,503 Members | 11,508 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

exporting imports to reduce exe size?


In looking at ways to reduce the size of exe's created with py2exe,
I've noticed that it will include a whole library or module even if I
only need one function or value from it.

What I would like to do is to import individual functions and then
export 'write' them to a common resource file and import that with
just the resources I need in them.

Has anyone tried this?

I'm considering using pickle to do it, but was wondering if this is
even a viable idea?

Is it possible to pickle the name space after the imports and then
reload the name space in place of the imports later?

Cheers,
Ron

Jul 18 '05 #1
3 1752
My first thought is what if the function you are using uses other
functions(maybe not exported by the module/package)? For example: if
some_func() makes a call to _some_weird_module_specific_func(), how
are you going to make sure you get the
_some_weird_module_specific_func function? This doesn't even start to
work when the function you are interested in is also using functions
from other modules/packages.

Besides, what py2exe is really doing is grabbing the .pyo or .pyc
files and throwing them in a zip file. Is it really worth the effort
to save a 100K or so, at most?

Chris

On Apr 12, 2005 10:54 AM, Ron_Adam <radam2_@_tampabay.rr.com> wrote:

In looking at ways to reduce the size of exe's created with py2exe,
I've noticed that it will include a whole library or module even if I
only need one function or value from it.

What I would like to do is to import individual functions and then
export 'write' them to a common resource file and import that with
just the resources I need in them.

Has anyone tried this?

I'm considering using pickle to do it, but was wondering if this is
even a viable idea?

Is it possible to pickle the name space after the imports and then
reload the name space in place of the imports later?

Cheers,
Ron

--
http://mail.python.org/mailman/listinfo/python-list

--
"I was born not knowing and have had only a little time to change that
here and there." -- Richard Feynman
Jul 18 '05 #2
On Tue, 12 Apr 2005 12:14:38 -0400, Chris Cioffi
<ev********@gmail.com> wrote:
My first thought is what if the function you are using uses other
functions(maybe not exported by the module/package)? For example: if
some_func() makes a call to _some_weird_module_specific_func(), how
are you going to make sure you get the
_some_weird_module_specific_func function? This doesn't even start to
work when the function you are interested in is also using functions
from other modules/packages.

Besides, what py2exe is really doing is grabbing the .pyo or .pyc
files and throwing them in a zip file. Is it really worth the effort
to save a 100K or so, at most?

Chris


I think in some cases it could save quite a lot more than 100k when
you consider that the module you include to get a single function,
then may include 3 modules for other functions you don't need, and
they in turn do the same.

After looking into it some, I agree it's probably not worth the
effort. Pythons pickle, shelve, and marshal functions don't work on
most module objects, so it's pretty much a dead end.

It would need be doable in a simple and general way to be worth while.

Thanks anyways,

Ron

Jul 18 '05 #3
Ron_Adam <radam2_@_tampabay.rr.com> writes:
In looking at ways to reduce the size of exe's created with py2exe,
I've noticed that it will include a whole library or module even if I
only need one function or value from it.

What I would like to do is to import individual functions and then
export 'write' them to a common resource file and import that with
just the resources I need in them.
It's not clear you can use a common "resources" file. You need to copy
the namespaces represented by each module into separate namespaces in
the file you're going to import. Multiple files can do this, but there
may be another approach.
Has anyone tried this?

I'm considering using pickle to do it, but was wondering if this is
even a viable idea?


Yeah, it's viable. LISP has been doing it for quite a while.

However, note that you have to figure out what objects in each module
are needed in each function you call from that module, and recursively
examine each of those objects. It's a non-trivial thing to do, and
will rely heavily on introspection of the objects in question.

<mike
--
Mike Meyer <mw*@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Jul 18 '05 #4

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

Similar topics

1
1935
by: Jacky11 | last post by:
I have a column name the Data type is MEMO The input is more than thousands of characters. When exporting, not all the information is exported. Who can I correct this problem? Thanks
8
1571
by: Alfonso Morra | last post by:
I am familiar with creating lean and mean WIN32 DLLS and exporting C functions via a DEF file (or cconv decorators), but I am wndering how I can export my C++ objects from my DLLs? Ideally, I...
3
1655
by: | last post by:
I'm picking up an 'IMPORTS' error for a simple database insert based on two input entry boxes in my form? It says an 'Imports' statement must preceede any declarations....... is this perahps the...
11
9551
by: Parrot | last post by:
Is there any routine I can call to reduce the size of an image file after uploading a file from a client. I am looking to reduce file sizes programmatically using C# in my web page after uploading....
1
1841
by: Jason.A.Oliver | last post by:
Hi everyone, Quick question. I'm very much a beginner with Access so I'm sorry if there's an easy way that I missed. I have several fairly large tables that I am trying to export from Access...
6
8178
by: sara | last post by:
I have what I think is a little strange...I have to get data from our payroll system into a specific format (fixed record length) as a .txt or .prn file only to upload to our 401k custodian. I...
23
2406
by: Thorsten Kampe | last post by:
Okay, I hear you saying 'not another naming conventions thread'. I've read through Google and the 'naming conventions' threads were rather *spelling conventions* threads. I'm not interested...
0
7330
by: support1 | last post by:
Hi, I have 10GB of harddisk space and now the harddisk space remaining 2GB because of the IBData1 size too big. As I'm check in the administrator tool. There is no any option to reduce or delete...
1
3278
by: replyrpatil | last post by:
What I am trying to do: I need to print a compact access report (font 6 size) created using RTF2 program developed by Stephen Lebans to generate a TIF image of custom size (5.5 in x 2.0 in) ...
0
7098
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
7364
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...
1
7017
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...
0
7470
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5604
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,...
1
5026
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
3174
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1524
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 ...
0
405
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...

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.