KLayout / klayout

KLayout Main Sources
http://www.klayout.org
GNU General Public License v3.0
808 stars 206 forks source link

Add a Layout.read_bytes() method that reads a layout from a byte array #1920

Open rocallahan opened 2 weeks ago

rocallahan commented 2 weeks ago

This is much more convenient and a bit more efficient than writing the bytes to a temporary file and reading that back in. It's useful when we have received a layout over the network or embedded in some file.

This makes a copy of the bytes but there doesn't seem to be any way to avoid that currently.

rocallahan commented 2 weeks ago

An even better API (for Python) would be to accept a Python io.BufferedIOBase which we would wrap in a tl::InputStreamBase but that's far more work.

klayoutmatthias commented 1 day ago

Thanks for this PR. This makes sense.

Version will be 0.29.9 - if you like, I can change that.

Basically, the reader can take data from "data:" stream "paths", but true bytes are easier to work with.

For symmetry, a writer to bytes would be needed too, right?

Matthias

klayoutmatthias commented 1 day ago

Another comment: Currently, passing the byte array as std::vector<char> involves a memory copy. So this facility is not good for passing huge files.