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 serhiy.storchaka
Recipients doerwalter, ezio.melotti, lemburg, martin.panter, serhiy.storchaka, vstinner
Date 2015-12-19.23:50:07
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <[email protected]>
In-reply-to
Content
The patch changes public interface. This breaks compatibility with third-party codecs implementing it.

We have found other solution to iterencode/iterdecode problem. For example we can buffer iterated values and encode with one step delay:

    prev = sentinel = object()
    for input in iterator:
        if prev is not sentinel:
            output = encoder.encode(prev)
            if output:
                yield output
        prev = input
    if prev is not sentinel:
        output = encoder.encode(prev, True)
        if output:
            yield output

Or remember the previous value and use it to calculate the empty value at the end (works only if input type supports slicing):

    prev = sentinel = object()
    for input in iterator:
        output = encoder.encode(input)
        if output:
            yield output
        prev = input
    if prev is not sentinel:
        output = encoder.encode(prev[:0], True)
        if output:
            yield output
History
Date User Action Args
2015-12-19 23:50:07serhiy.storchakasetrecipients: + serhiy.storchaka, lemburg, doerwalter, vstinner, ezio.melotti, martin.panter
2015-12-19 23:50:07serhiy.storchakasetmessageid: <[email protected]>
2015-12-19 23:50:07serhiy.storchakalinkissue23231 messages
2015-12-19 23:50:07serhiy.storchakacreate