Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parallelise *.point(pos) using NumPy #68

Closed
abey79 opened this issue Nov 18, 2020 · 2 comments
Closed

Parallelise *.point(pos) using NumPy #68

abey79 opened this issue Nov 18, 2020 · 2 comments

Comments

@abey79
Copy link

abey79 commented Nov 18, 2020

Background

In my project (https://github.com/abey79/vpype), I need to load SVG and convert all geometries (including curves) to line strings with controllable step size. I'm not 100% happy with the current solution and I'm looking at alternatives and svg.path could certainly help.

Conceptually, this is the way I'd do thing with a non-parallel version of *.point(pos):

for elem in path:
    if isinstance(elem, svg.Line):
        coords = [elem.start, elem.end]
    else:
        step = int(math.ceil(elem.length() / quantization) + 1)
        coords.extend(elem.point(i / step) for i in range(step + 1))

    # append coords to the output buffer

The number of calls to elem.point() can be very high (some user have A2+ SVGs and typically using 0.1mm step size) and this incurs significant loading times.

Proposal

Introduce a dependancy on NumPy and allow *.point(pos) to accept NumPy arrays of float. In this case, the function would return a Numpy array of complex instead of a single complex. A cursory look at the code indicates that minimal changes would be required for this to work (mainly in Arc.point() and Path.point()).

With this issue I'm hoping to probe this project's maintainers willingness to go in this direction, since a dependancy
would be introduced (this project's first as far as I can tell!). This issue also has some loose ties with #31 and #36, as NumPy could be helpful in the application of transforms.

@regebro
Copy link
Owner

regebro commented Nov 18, 2020

I will not introduce a dependency on NumPy, sorry. This is a small lightweight library.
It feels like there must be a better way to parallelize this...

@abey79
Copy link
Author

abey79 commented Nov 18, 2020

I will not introduce a dependency on NumPy, sorry.

Noted.

It feels like there must be a better way to parallelize this...

If so, it is not known to me.

@abey79 abey79 closed this as completed Nov 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants