Skip to content

Vectorize update() #21

Description

@jmalkin

Looping in python is slow. We should enable update() with multiple inputs where C++ handles the iteration, for all sketches.

For sketches that take primitive types this is simple and can be done by overloading update(). For item containers it may be less straightforward since a list is a type of object, meaning an overloaded may treat the list as a single thing to ingest.

IIRC, the wrappers (both pybind11 and nanobind) iterate through the possible methods in the order ini which they were declared in the wrapper definition, which is not good for API design: Lack of transparency, internal rearranging of code can cause side-effects, etc. So we probably need a different method name. Then we run into the question of whether we should use an overload where practical and a different name where necessary or if we go for more consistency.

Activity

  1. changed the title [-]Vectorize update[/-] [+]Vectorize update()[/+] on Dec 8, 2023
  2. jmalkin commented on Jan 12, 2024

    @jmalkin
    ContributorAuthor

    Proposing that we allow update() to operate on vectors for primitives, but because that won't work for generic objects we'll use update_batch(). The latter will also exist and work for primitives.

  3. c-dickens commented on Jan 18, 2024

    @c-dickens
    Contributor

    I second this change and am fine with the naming. This idea should not be too unusual for python users (for example, there are fit and partial_fit methods in scikit-learn).

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