Skip to content

Serialization is slow #114

Description

@petr-stefan-szn

Hi,

I have a project that creates some calendar events and outputs them in ical representation. Some of them can include attachments as base64 encoded binary data in ATTACH property. Here the serialization is really slow, like several seconds for 10 MB pdf file.

I tracked down the issue to the foldOneLine function (https://github.com/py-vobject/vobject/blob/master/vobject/base.py#L898). If I use something like this, the same output is generated in a fraction of a second.

def customFoldOneLine(outbuf, input, line_length=75):
    chunk_size = line_length - 1
    for start in range(0, len(input), chunk_size):
        prefix = "\r\n " if start > 0 else ""
        outbuf.write(f"{prefix}{input[start:start + chunk_size]}")
    outbuf.write("\r\n")


vobject.base.foldOneLine = customFoldOneLine

I don't think the old complex logic is needed anymore in python3.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions