[Numpy-discussion] savetxt to a string?
Wed Dec 22 09:24:02 CST 2010
> On Wed, Dec 22, 2010 at 1:53 PM, Neal Becker <firstname.lastname@example.org> wrote:
>> Peter wrote:
>>> On Wed, Dec 22, 2010 at 1:08 PM, Neal Becker <email@example.com>
>>>> Is the formatting of savetxt available with a string as the
>>>> If not, shouldn't this functionality be factored out of savetxt?
>>> Have you tried using a StringIO handle?
>> Yup. But wouldn't it be cleaner to factor out this functionality and
>> make saving to a file use this?
> I doubt it.
> I would think from a code point of view no - taking filenames or handles
> means you can write everything using handle.write(...) statements, and
> send the data to disk (or a StringIO handle) gradually. This scales well
> with large data.
> If you wanted a single code base to support filenames, handles, or
> output as a string I think you'd be forced to build a large string in
> memory, and then (if applicable) write it to disk (in one go). This
> won't scale well with large data.
More information about the NumPy-Discussion