Skip to content

Speed up ichunked #797

@james-wasson

Description

@james-wasson

Pull request

#793

Changes

I was trying to create my own ichunked method and found this library and thought I might contribute. This new method implementation runs about 2x faster than the current implementation due to it not using any user created iterators (eg. classes with the next() method).

There should be no changes visible to the end user other than the speed difference unless the user is relying on the private class _IChunk.

This implementation uses a scoped variables within a wrapping method scope to modify the state of the generator on the fly.

I have tested and timed this method extensively using both calls to next() and just looping. I have also tried modifying the state part way through iteration and I have not run across any issues.

A simple timing test:

  • Before
    image
  • After
    image

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