cython/cython — pull request #232 by nnemkin (2013-05-22 06:31:38+00:00)
Title: Added support for cpdef enum (take 2)

This is a resurrection of [PR45](https://github.com/cython/cython/pull/45).

I've started with @vitek's patch, fixed .pxd enum processing and added more tests.

To answer comments in the original thread:

* Enums as Python classes is a completely different feature. `cpdef enum` simply exposes C enumeration values, which are always module scoped.
Therefore, `modname.VALUE_NAME` has the same meaning in Cython (C level) and Python.
* Cython type system and its handling of enum types is not affected in any way.

My use case: I have two modules full of numeric constants (~500 in total) that are used throughout the project. Currently it is impossible to expose them to Python without duplicating every definition. Also, it is impossible to declare Python values in the same module as C enum values, due to name conflict. (I have considered using ``globals().extend(VALUE=..., etc)`` but opted for this patch instead.)

Docs will be written if/when the change is approved.