<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 8 March 2017 at 04:15, Ethan Furman <span dir="ltr"><<a href="mailto:ethan@stoneleaf.us" target="_blank">ethan@stoneleaf.us</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 03/07/2017 09:41 AM, Brett Cannon wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I don't think a common practice has bubbled up yet for when there's both synchronous and asynchronous versions of an API<br>
(closest I have seen is appending an "a" to the async version but that just looks like a spelling mistake to me most of<br>
the time). This is why the question of whether separate modules are a better idea is coming up.<br>
</blockquote>
<br></span>
I'm undoubtedly going to show my ignorance with this question, but is it feasible to have both sync and async support in the same object?<br></blockquote><br></div><div class="gmail_quote">As Jelle says, it depends on the API. For contextlib, we've already decided that 'asynccontextmanager' and 'AsyncExitStack' are going to be parallel APIs, as even though they *could* be the same object, they're much easier to document if they're separate, and you get a form of "verb agreement" at both definition time and at runtime that lets us be confident of the developer's intent.<br><br></div><div class="gmail_quote">For simpler APIs like "closing" though, I'm leaning more towards the "just make it work everywhere" approach, where the async protocol methods use "await obj.aclose()" if the latter is defined, and a synchronous "obj.close()" otherwise.<br></div><br></div><div class="gmail_extra">Cheers,<br></div><div class="gmail_extra">Nick.<br clear="all"></div><div class="gmail_extra"><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">Nick Coghlan | <a href="mailto:ncoghlan@gmail.com" target="_blank">ncoghlan@gmail.com</a> | Brisbane, Australia</div>
</div></div>