[Patches] [ python-Patches-685051 ] fix for 680789: reprs in arraymodule

SourceForge.net noreply@sourceforge.net
Wed, 23 Apr 2003 11:04:35 -0700


Patches item #685051, was opened at 2003-02-11 19:45
Message generated for change (Comment added) made by logistix
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=685051&group_id=5470

Category: Modules
Group: Python 2.3
Status: Closed
Resolution: Accepted
Priority: 5
Submitted By: logistix (logistix)
Assigned to: Raymond Hettinger (rhettinger)
Summary: fix for 680789: reprs in arraymodule

Initial Comment:
arraymodule's repr used "string += ',' + el" for each 
element in the array.  Lists and dicts did a string.join to 
build the repr.

Attached patch builds a tuple of array elements and 
then joins them. 

This fixes the time issue, but I don't know enough about 
how you guys manage memory in each case to tell what 
impact that'll have on really, really big arrays (although I 
imagine it takes more memory).

----------------------------------------------------------------------

>Comment By: logistix (logistix)
Date: 2003-04-23 13:04

Message:
Logged In: YES 
user_id=699438

Did you look at the second patch I posted?

My concern is that the intermediate list temporarily requires 
an extra 'sizeof(PyObject) x len(array)', instead of 'sizeof
(int/char/whatever) x len(array)' to do a repr now.  This is a 
pretty big multiple, right?

Current patch is fine with me if it's fine with you.  Just wanted 
to bring it up.

----------------------------------------------------------------------

Comment By: Raymond Hettinger (rhettinger)
Date: 2003-04-23 12:28

Message:
Logged In: YES 
user_id=80475

I substantially re-worked and simplifed the patch and have 
applied it as:  arraymodule 2.87

Thanks for addressing the bug report.  Otherwise, this 
might not have gotten done for Py2.3.


----------------------------------------------------------------------

Comment By: logistix (logistix)
Date: 2003-02-22 14:41

Message:
Logged In: YES 
user_id=699438

As I learn more about the sizeof PyObjects, I don't really like 
my last patch.  It creates too many intermediate PyObjects 
at at the same time.  This patch uses two passes to build the 
repr, reducing the number of temporary PyObjects at any 
given time to 4 or five, instead of len(array) + 5.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=685051&group_id=5470