StringChain -- a data structure for managing large sequences ofchunks of bytes
steve at holdenweb.com
Tue Mar 30 15:46:20 CEST 2010
Lie Ryan wrote:
> On 03/29/2010 01:59 AM, Steven D'Aprano wrote:
>> On Sun, 28 Mar 2010 06:48:21 +1100, Lie Ryan wrote:
>>> On 03/22/2010 07:07 PM, Steven D'Aprano wrote:
>>>> Perhaps you should have said that it was a wrapper around deque giving
>>>> richer functionality, rather than giving the impression that it was a
>>>> brand new data structure invented by you. People are naturally going to
>>>> be more skeptical about a newly invented data structure than one based
>>>> on a reliable, component like deque.
>>> Well, technically StringChain is not a data structure in the first
>>> place. StringChain is a string;
>> And strings are data structures, as are arrays and structs. Just because
>> they're simple data structures made directly from primitives rather than
>> rich, complex structures, doesn't mean they're not data structures.
> Array is a way to structure data and thus a data structure; array is the
> concept of structuring data using contiguous memory with elements
> addressed by an index. string is just a contiguous memory reserved to
> store data, or in other words: string is an array. This is what I meant
> when I said string is not itself a data structure.
>>> a string that is implemented using deque
>>> data structure to make appending algorithmically efficient. It is not a
>>> data structure, in the sense that I can't put arbitrary "thing" into the
>>> data structure.
>> Any "thing" that can be pickled or serialised can be put into a string.
> Fair enough, you're right to think so but IMHO I disagree. Streams (or
> perhaps 'blob' to avoid the connotation of FIFO) are the data structure
> which you can put anything pickleable/serialisable into, but string (the
> implementation of stream/blob using array) are just a special case of
> array data structure and not a different, separate data structure than
> Perhaps I should not make such a bold claim as saying string is not data
> structure; what I have in mind is that string is just a special case of
> array and not distinctly separate data structure than array.
While this may be true conceptually it's certainly not true in Python
(and in Python you need to be careful to distinguish between lists and
arrays, since it does have both types).
>From the point of view of the language, strings are primitives. But
every Python implementation uses a data structure to store them, and the
structure is definitely not the same as is used to store lists, or
arrays (which in Python are container types, whereas the string isn't
because the individual indexable elements are immutable).
As always, it's better to seek common ground than pick the nits: I don't
think that there's really that much difference between your approach and
Steven's, but he's a well-known nit-picker (and we are *sometimes*
grateful for it).
Steve Holden +1 571 484 6266 +1 800 494 3119
See PyCon Talks from Atlanta 2010 http://pycon.blip.tv/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS: http://holdenweb.eventbrite.com/
More information about the Python-list