Skip to content

feat: Add TIFF.open_sync to synchronously open a TIFF#176

Open
kylebarron wants to merge 6 commits intomainfrom
kyle/sync-open
Open

feat: Add TIFF.open_sync to synchronously open a TIFF#176
kylebarron wants to merge 6 commits intomainfrom
kyle/sync-open

Conversation

@kylebarron
Copy link
Member

@kylebarron kylebarron commented Jan 23, 2026

Change list

  • Add a new synchronous API to open a TIFF TIFF.open_sync.

Questions

I think the "primary" API of the library should be async, in the sense that if someone is doing synchronous operations, there's not much of a point of using async-tiff over rasterio.

But I think it makes sense to have sync operations because 1) it's not hard to implement sync wrappers and 2) it's useful for testing.

But if we do have sync operations, then we need to be consistent on naming, and it seems like the most consistent naming is to make the async method end with an _async suffix.

@vincentsarago
Copy link
Member

I think the "primary" API of the library should be async, in the sense that if someone is doing synchronous operations, there's not much of a point of using async-tiff over rasterio.

I would then say that you don't even need to have async_open

The whole library is named async so the user should expect to have to use await for all the methods

@kylebarron
Copy link
Member Author

I think the "primary" API of the library should be async, in the sense that if someone is doing synchronous operations, there's not much of a point of using async-tiff over rasterio.

I would then say that you don't even need to have async_open

The whole library is named async so the user should expect to have to use await for all the methods

The idea is that an end user might need to just construct the GeoTIFF instance to pass to a library. But where the user themselves doesn't want or know how to touch async. As in the example I provided above with Lonboard.

The question is whether it's better to have

  • sync: open_sync, async: open
  • sync: open, async: open_async

The former is more "async-native" while the latter maintains better compatibility with obstore. Obstore is similar in the sense that users should use the async API over the sync one, but it also makes you suffix with _async in order to use any async APIs

@vincentsarago
Copy link
Member

I don't want to be a blocker here and if it's the same with obstore let's use open_async

@maxrjones
Copy link
Member

+1 on mirroring obstore's naming conventions

@kylebarron
Copy link
Member Author

Another option is to use different names entirely:

  • sync: __init__
  • async: open

Since in Python __init__ can't be async, we could set that. (Technically, pyo3 implements __new__, not __init__, so I think it might be possible to make an async constructor, but users wouldn't be used to it)

@hrodmn
Copy link

hrodmn commented Jan 24, 2026

+1 for *_async functions and methods

I agree with @vincentsarago that the name of the library suggests async features so async functions should be expected, but I think consistency with other related/familiar APIs like obstore is really valuable and will save us all some headaches.

@weiji14
Copy link
Member

weiji14 commented Jan 24, 2026

I think the "primary" API of the library should be async, in the sense that if someone is doing synchronous operations, there's not much of a point of using async-tiff over rasterio.

I would then say that you don't even need to have async_open

The whole library is named async so the user should expect to have to use await for all the methods

I would lean towards keeping things async only. Unlike obstore/object_store which has a manageable spec, (Geo)TIFF has too many things going on at the low level (see advice from #7), and I think doubling the amount of methods would lead to more confusion (see zarr-python's async and sync APIs). Also it looks duplicative if someone does

import async_tiff

await async_tiff.open_async(...)

We could make _async/_sync versions in async-geotiff, but I'd vote to keep things async only here.

@kylebarron
Copy link
Member Author

I'm leaning now towards:

  • This is an async-first library, whereas obstore is "half and half to support both equally"
  • We should make the async operations the most obvious, while allowing fallbacks to synchronous APIs in some cases
  • Therefore:
    • async open should be called await TIFF.open()
    • sync open should be called: TIFF.open_sync()

Any final thoughts?

@kylebarron kylebarron changed the title feat!: Synchronous open for Python TIFF feat: Add TIFF.open_sync to synchronously open a TIFF Jan 26, 2026
@kylebarron
Copy link
Member Author

I'm inclined to not merge this for the current release, and then we can keep thinking about whether this is useful

@vincentsarago
Copy link
Member

I'm still not super convinced by one or the other. To be honest I was mostly surprised that async-tiff would provide synchronous methods.

If this not a user request, I would put this on hold to be honest.

I would not go for open_sync if we expect user to use obstore as well (because obstore does the opposite with open_async)

@hrodmn hrodmn removed their request for review March 19, 2026 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants