Le 15/07/2022 à 21:15, DoubleFelix a écrit :
Hello,

I'm using lilypond to programmatically generate sheet music. I already have a system in place to crop the SVGs, but now I need to load them in my software. I could use the default behavior of letting lilypond write to some file, and then reading it, but file I/O tends to be pretty expensive, especially when you're doing it in bulk like I am, so I'd like to avoid that.

My question is this: Is there a way to get lilypond to write the output to stdout to save on performance, or do I need to use a file as a middleman? For reference, my current command is:
"lilypond --svg --loglevel=none file.ly <http://file.ly>"


I don't think this exists. On the other hand, I strongly
doubt that file I/O can prove expensive compared to the
time required to process the LilyPond file. For example,
with Python,

$ time lily -s --svg input/regression/parenthesize.ly

real    0m0,719s
user    0m0,637s
sys    0m0,061s

$ python
Python 3.10.5 (main, Jun  9 2022, 00:00:00) [GCC 12.1.1 20220507 (Red Hat 12.1.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from pathlib import Path
>>> from timeit import timeit
>>> timeit("Path('parenthesize.svg').read_bytes()", number=1000, globals=globals())
0.015240808002999984


As you can see, the time taken to read the output SVG
file was 2% of the time to compile the file in this example.

Best,
Jean


Reply via email to