-
-
Notifications
You must be signed in to change notification settings - Fork 53
Notes from meeting with Cinder devs
Stepan Sindelar edited this page Jun 8, 2022
·
4 revisions
Suggested new API: HPy_ssize_t HPyUnicode_CopyUTF8ToBuffer(ctx, buffer, start, nsize, handle)
Iterating things effectively?
- iterating a dictionary (PyDict_Next)?
- read-only view on dictionary items/keys?
HPy buffer[16];
start = 0;
while (...)
HPy_ssize_t n = HPy_ToBuffer(ctx, start, buffer);
start += 16;
for (i = 0; i< min(n, 16); ++i)
HPy_Length(ctx, buffer[i])
C compiler could optimize the inner loop nicely at least on CPython ABI.
Alternative to opaqueness:
- pass non-opaque structs + field offsets?
struct {
HPy the_list;
HPy_ssize_t length;
} HPyListView;
foo(HpyContext *ctx, HPyListView self);
How to implement HPy:
- definition of the context structure: hpy/devel/include/hpy/universal/autogen_ctx.h
- generated from this: hpy/tools/autogen/public_api.h
- using this configuration: hpy/tools/autogen/conf.py
- the HPy internal autogen tools generate also the trampolines, which are part of the header files that are the same for all implementations, e.g.:
- HPy HPyLong_FromLong(HPyContext *ctx, long l) { return ctx->ctx_Long_FromLong(ctx, l); }
Idea regarding the module state + argument clinic:
struct {
HPy my_type1;
int my_counter;
} MyModuleContext;
SIGNATURE(...)
foo(HPyContext *ctx, MyModuleContext *moduleCtx) {
return HPy_New(ctx, moduleCtx->my_type1);
}
ModuleDef module = {
//...
cotext_size = sizeof(MyModuleContext),
};
static HPy init_my_module_impl(HPyContext *ctx) {
HPy type_handle = HPyType_FromSpec(ctx, &module);
// ...
HPyModuleContext_Add(ctx, offsetof(MyModuleContext, my_type1), type_handle);
HPy_Close(ctx, type_handle);
// ...
}
Pointers to issues that were discussed during the meeting:
- String builder API proposal: https://github.com/hpyproject/hpy/issues/214
- "Unboxed signature" functions for JIT (argument clinic): https://github.com/hpyproject/hpy/issues/129
- We need some API to check interrupts, call safepoints, etc.
- 5 September 2024
- 4 April 2024
- 7 March 2024
- 1 February 2024
- 11 January 2024
- 7 December 2023
- 9 November 2023
- 5 October 2023
- 14 September 2023
- 3 August 2023
- 6 July 2023
- 1 June 2023
- 4 May 2023
- 13 April 2023
- 2 March 2023
- 2 February 2023
- 12 January 2023
- 1 December 2022
- 3 November 2022
- 6 October 2022
- 8 September 2022
- 4 August 2022
- 7 July 2022
- 2 June 2022
- 5 May 2022
- 7 April 2022
- 3 March 2022
- 3 February 2022
- 13 January 2022
- 2 December 2021
- 4 November 2021
- 7 October 2021
- 2 September 2021
- 12 August 2021
- 8 July 2021
- 6 May 2021
- 4 March 2021
- 7 January 2021
- 3 December 2020
- 5 November 2020