Feature Requests item #1190033, was opened at 2005-04-26 01:59 Message generated for change (Comment added) made by rhettinger You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1190033&group_id=5470
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Python Library Group: None Status: Open Resolution: None Priority: 5 Submitted By: Josiah Carlson (josiahcarlson) Assigned to: Nobody/Anonymous (nobody) Summary: The array module and the buffer interface Initial Comment: It would be terribly convenient if array objects were willing to take any object supporting the buffer interface as initialization or extension via a.fromstring(). They currently offer the buffer interface for other objects to read/write once the array has been created, but they do not accept buffers during creation or extension (except for the typecode 'c'). ---------------------------------------------------------------------- >Comment By: Raymond Hettinger (rhettinger) Date: 2005-06-03 01:42 Message: Logged In: YES user_id=80475 I recommend dropping this one and leaving the API alone. The improvement would be so small that it isn't worth the time to review it, test it, and introduce another version incompatability (something that runs on Py2.5 that won't run on Py2.4). ---------------------------------------------------------------------- Comment By: Josiah Carlson (josiahcarlson) Date: 2005-06-02 21:04 Message: Logged In: YES user_id=341410 I had assumed str(buf) copied the contents of the buffer, but I was mistaken (read the source Josiah). As I stated in my previous post, array.fromstring takes buffer objects, so the documentation should be updated in that case, which I can do if desired. Honestly, I am also +0 on the patch. I think it is convenient for completeness sake, but with array.fromstring, and str(buf) being fast, it isn't necessary. ---------------------------------------------------------------------- Comment By: Raymond Hettinger (rhettinger) Date: 2005-06-02 20:12 Message: Logged In: YES user_id=80475 +0 It is not unreasonable to want to generalize the interface. OTOH, the str() workaround is trivial and explicit: >>> buf = buffer('abcdefghi', 1, 5) >>> array('b', str(buf)) array('b', [98, 99, 100, 101, 102]) ---------------------------------------------------------------------- Comment By: Josiah Carlson (josiahcarlson) Date: 2005-04-28 07:39 Message: Logged In: YES user_id=341410 I couldn't sleep, so I started working on it. Note: a.fromstring(buf_obj) works in Python 2.3 and 2.4, it just isn't documented, nor is it exposed via array_new. I've got less than 20 lines of changes that seem to be necessary for array(typecode, buf) to be supported, including documentation and unittest updates. I'll sleep on it (I'm getting tired) and upload it tomorrow. ---------------------------------------------------------------------- Comment By: Josiah Carlson (josiahcarlson) Date: 2005-04-28 01:37 Message: Logged In: YES user_id=341410 Not right now, but I could probably have one for you tomorrow. You want doc updates and tests too? ---------------------------------------------------------------------- Comment By: Raymond Hettinger (rhettinger) Date: 2005-04-28 00:20 Message: Logged In: YES user_id=80475 Do you have a patch? ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1190033&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com