[Cython] Utility Codes and templates

Stefan Behnel stefan_ml at behnel.de
Fri Jul 22 13:26:31 CEST 2011

mark florisson, 22.07.2011 12:12:
> For my work on the _memview branch (and also on fused types) I noticed
> that UtilityCodes started weighing heavily on me in their current
> form, so I wrote a little loader in the _memview branch:
> https://github.com/markflorisson88/cython/commit/e13debed2db78680ec0bd8c343433a2b73bd5e64#L2R110
> The idea is simple: you put your utility codes in Cython/Utility in
> .pyx, .c, .h files etc, and then load them. It works for both
> prototypes and implementations, for UtilityCode and CythonUtilityCode:
> myutility.c
> // UtilityProto: MyUtility
> header code here
> // UtilityCode: MyUtility
> implementation code here

Actually, if we use a template engine anyway, why not simplify this 
further? We could just evaluate the template twice, once with 
target="proto" and once with target="impl", and use the conditionals of the 
template language to output the right code section depending on that parameter.


More information about the cython-devel mailing list