Editable strings anyone?

Paul Rubin phr-n2002a at nightsong.com
Sun Feb 17 19:09:17 EST 2002


sjmachin at lexicon.net (John Machin) writes:
> The array module is one of the included batteries that needs a
> publicity agent. It is good value for:

Thanks.  I knew about the array module but it wasn't at all clear from the
docs that it does what I need.  It's still not clear from the source code whether
it does everything I need, but it looks promising and I'll have to
examine it further.


> It's a pleasant surprise that the re module supports searching etc on
> 'c' arrays.

Yes, this was not documented at all.

> You'll find one nuisance when working with 'c' arrays; it doesn't
> support coercing an ordinary string to an array -- you have to do it
> yourself. For example:
> 
> x = array.array('c', 'abc')
> x = x + 'def'
> 
> doesn't work. You have to do 
> 
> x = x  + array.array('c', 'def')

That doesn't bother me much.

> >  So I guess I'll submit a doc bug saying the above items should be described.
> 
> Certainly the re docs should be a tad more explicit about what a
> "string" can be, or what behaviour(s) it must provide.

Next question (what I need to examine the source for):  what happens if you do

  x = array.array('c','a'*1000000)
  del x[500000]
  del x[500000]
  del x[500000]

Do a half million characters get copied around for each of the delete operations?



More information about the Python-list mailing list