pyosmium icon indicating copy to clipboard operation
pyosmium copied to clipboard

Consider Writer to take a FileBuffer

Open cmahnke opened this issue 1 month ago • 1 comments

For symmetry reason (Reader also does it) I would like to propose that a Writer might also take FileBuffer to operate directly in memory. This can certainly crash the application for huge data sets, but might speed up operations on small to medium data sets, especially when there are multiple passes needed.

cmahnke avatar Nov 16 '25 22:11 cmahnke

The same applies to osmium.MergeInputReader(), the add_file() method doesn't take a FileBuffer. To make matters worse the FileBuffer is missing a method to get the underlying buffer...

cmahnke avatar Nov 17 '25 10:11 cmahnke

This is somewhere on my TODO list. Unfortunately it is not quite as trivial to implement as a buffer for the reader. The Reader buffer has a static size and is read-only, so you can just hand it to libosmium. The Writer buffer on the other hand ideally has to grow with the data. That makes implementing the interface between Python and libosmium interesting.

Regarding saving data for multiple passes, I was thinking to expose libosmium's buffers for temporary storage. Not only would it be super-fast to reread, it would also be possible to create indexes over them for direct access. But that would be a different issue.

lonvia avatar Dec 21 '25 09:12 lonvia