Ticket #777 (new enhancement)
Metaclasses to generate cdef'ed Classes
| Reported by: | valmynd | Owned by: | somebody |
|---|---|---|---|
| Priority: | minor | Milestone: | wishlist |
| Component: | Code Generation | Keywords: | |
| Cc: |
Description
Here are some ideas of how this could be accomplished:
- evaluate cdef-Classes which are using a Metaclass before any other classes
- create temporary pyd and pyx files for any cdef-class that uses cdef-metaclasses
- those temporary classes need to be re-evaluated if anything changes in the original
Example Scenario:
@cython.cclass class FormMeta(type): @classmethod def __prepare__(metacls, name, bases, **kwargs): return OrderedDict() def __init__(cls, name, bases, attrs): # add some attributes and methods to cls, in order to # have less boilerplate to write for each form class return type.__init__(cls, name, bases, attrs) @cython.cclass class UserForm(metaclass=FormMeta): name = TextField()
Benefits:
- Once the Extension Module is built, there would be no need to do process the creation/manipulation via metaclasses, thus reduce startup time for application
- Have all the benefits of cdef-Classes, like lower memory footprint, when there might be hundreds of those classes with lots of data in them
- Have all the benefits of python beeing both very dynamic and flexible and simple to use
I know there are many issues which have a higher priority right now, but a discussion about this would be very nice.
Change History
Note: See
TracTickets for help on using
tickets.
