[FEAT] def_async
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 18k
- Forks
- 2.3k
- Avg merge
- 5d 17h
- Merged PRs (30d)
- 10
Description
i made a simple Awaitable class in c++ to support pythons async/await syntax with c++ deferred functions:
template<typename ResultType>
class Awaitable : public std::enable_shared_from_this<Awaitable<ResultType>>{
public:
Awaitable();
Awaitable(std::future<ResultType>&);
std::shared_ptr<Awaitable<ResultType>> __iter__();
std::shared_ptr<Awaitable<ResultType>> __await__();
void __next__();
private:
std::future<ResultType> future;
};
is this something that would have a chance to land in pybind11?
So, supporting an interface like:
m.def_async("name", &function_returning_a_future);
What seems to be missing for this is a StopIteration exception type with templated "return" type.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The proposal centers on a C++ Awaitable class and a hypothetical m.def_async("name", &function_returning_a_future) entry point. Start by determining whether this interface belongs in pybind11 and how the proposed await/next behavior and templated StopIteration return should be scoped; done requires an agreed design and implementation plan.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, python
- Domain
- api
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 18/100