Skip to content

Conversation

@chopan050
Copy link
Contributor

Related PR: #3292

  • I rewrote VMobject.append_points() to build a new NumPy array from scratch with np.empty() and copy the old and new points in it, rather than using the slower np.append(). This method is slightly faster, which is useful because this method can get called a lot.
  • Also rewrote VMobject.add_points_as_corners(), which repeatedly called VMobject.add_line_to() and thus repeatedly called VMobject.append_points(). Instead of allocating N arrays, one for every time we append a new line to one to the N points, this method now allocates a single array from the beginning and copies all the necessary points in it.
  • At .add_line_to(), .add_points_as_corners() and .set_points_as_corners(), instead of always calling np.linspace(0, 1, self.n_points_per_cubic_curve), which is slow when being called many times, I memoized the result into a VMobject._bezier_t_values NumPy array and simply used that one.
  • Minor optimizations in .start_new_path() and .add_subpath().
  • Added docstrings for some methods.

Reviewer Checklist

  • The PR title is descriptive enough for the changelog, and the PR is labeled correctly
  • If applicable: newly added non-private functions and classes have a docstring including a short summary and a PARAMETERS section
  • If applicable: newly added functions and classes are tested

Copy link
Member

@JasonGrace2282 JasonGrace2282 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

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

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants