This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author josh.r
Recipients Tommy.Carstensen, josh.r
Date 2014-03-24.23:18:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1395703086.66.0.158862152923.issue20992@psf.upfronthosting.co.za>
In-reply-to
Content
On memory: Yeah, it could be if the file didn't include any newline characters. Same problem could apply if a text input file relied on word wrap in an editor and included very few or no newlines itself.

There are non-fileinput ways of doing this, like I said; if you want consistent performance, you'd probably use one of them. For example, using the two arg form of iter:

    from functools import partial

    def bytefileinput(files):
        for file in files:
            with open(filename, "rb") as f:
                yield from iter(partial(f.read, 1), b'')

Still kind of slow, but predictable on memory usage and not to complex.
History
Date User Action Args
2014-03-24 23:18:06josh.rsetrecipients: + josh.r, Tommy.Carstensen
2014-03-24 23:18:06josh.rsetmessageid: <1395703086.66.0.158862152923.issue20992@psf.upfronthosting.co.za>
2014-03-24 23:18:06josh.rlinkissue20992 messages
2014-03-24 23:18:06josh.rcreate