REPOST: Re: Efficient storage of floats

Martin von Loewis loewis at informatik.hu-berlin.de
Wed Dec 26 19:27:58 EST 2001


"Francois Petitjean" <littlejohn.75 at free.fr> writes:

> Is it possible to have a quantitative assessment of the overhead of the two
> methods 1(list) or 2(array)? (overhead in memory footprint or CPU cycles).

Getting the overhead in memory consumption is possible, but it is
quite time consuming (you'll have to consider malloc overhead as
well); see my earlier articles on "size of objects" for examples. It
is well possible that the list version consumes five times or more than
memory than the array version.

On CPU cycles, you get additional indirections with the lists, but
this is difficult to estimate - that is best done through bench
marking.

> And is it interesting to preinitialize the structure? The number of
> points is typically 800*2 (for symmetry) that is say up to 8000
> floats.

Depends on how often you destroy and recreate them, compared to
actually using the data. For a list, pre-allocation is quite
pointless, since the list will over-allocate anyway. For an array, it
may be reasonable.

BTW, pre-allocating [(0.0, 0.0, 0.0)*800] is worse than pre-allocating
[None*800]. All 800 references will point to the same object in each
case, only that "creating" None is more efficient than creating the
tuple.

Regards,
Martin

========= WAS CANCELLED BY =======:
Path: news.sol.net!spool1-nwblwi.newsops.execpc.com!newsfeeds.sol.net!news-out.visi.com!hermes.visi.com!newsfeed.direct.ca!look.ca!newsfeed.dacom.co.kr!feeder.kornet.net!news1.kornet.net!ua4canc3ll3r
From: Martin von Loewis <loewis at informatik.hu-berlin.de>
Newsgroups: comp.lang.python
Subject: cmsg cancel <j4adw5h5gx.fsf at informatik.hu-berlin.de>
Control: cancel <j4adw5h5gx.fsf at informatik.hu-berlin.de>
Date: Mon, 31 Dec 2001 03:18:33 GMT
Organization: A poorly-installed InterNetNews site
Lines: 2
Message-ID: <cancel.j4adw5h5gx.fsf at informatik.hu-berlin.de>
NNTP-Posting-Host: 211.57.49.2
X-Trace: news2.kornet.net 1009776204 27193 211.57.49.2 (31 Dec 2001 05:23:24 GMT)
X-Complaints-To: usenet at news2.kornet.net
NNTP-Posting-Date: Mon, 31 Dec 2001 05:23:24 +0000 (UTC)
X-No-Archive: yes
X-Unac4ncel: yes
X-Commentary: I love NewsAgent 1.10 and the Sandblaster Cancel Engine Build 74 (19 March 1999)

This message was cancelled from within Mozilla.



More information about the Python-list mailing list