Message51675
josiahcarlson:
I think you misunderstood options 2 and 3. The empty string (option 2) or
nonempty but fixed size string (option 3) would *only* be returned in the
event of an allocation failure, aka "the process is out of memory". Since
it's out of memory yet trying to allocate more, it has *already* failed.
My goal in proposing options 2 and 3 was that, when this happens (and it
eventually will), Python would fail *gracefully* with an exception, rather
than *miserably* with a bus error.
As for writing a wrapper, I'm just not interested. I'm a strong believer
in "There should be one--and preferably only one--obvious way to do it",
and I feel a special-purpose wrapper class for good string performance
adds mental clutter. The obvious way to do string concatenation is with
"+"; the obvious way to to string slices is with "[:]". My goal is to
make those fast so that you can use them *everywhere*--even in
performance-critical code. I don't want a wrapper class, and have no
interest in contributing to one.
For what it's worth, I came up with a fifth approach this morning while
posting to the Python-3000 mailing list: pre-allocate the str buffer,
updating it to the correct size whenever the lazy object changes size.
That would certainly fix the problem; the error would occur in a much
more reportable place. But it would also slow down the code quite a lot,
negating many of the speed gains of this approach. |
|
Date |
User |
Action |
Args |
2007-08-23 15:56:04 | admin | link | issue1629305 messages |
2007-08-23 15:56:04 | admin | create | |
|