dfujim / mudpy

MUon Data file IO
GNU General Public License v3.0
4 stars 3 forks source link

Deprecation of DEF in Cython #9

Open rmlmcfadden opened 8 months ago

rmlmcfadden commented 8 months ago

See the guide for Migrating from Cython 0.29 to 3.0.

The only DEFs in mudpy were introduced as part of #4 to avoid using hard-coded values in the "friendly" C-function calls.

Eventually, we should replace the DEFs with one of the strategies recommended in the guide.

dfujim commented 8 months ago

I'm not quite sure what to do here other than hard code it. The suggestions in the link you provided don't work in this cae. For example, by replacing DEF with cdef int I get the following compile error at many points:

          """Returns python string. Max number of characters: TITLE_CHAR_SIZE."""
          cdef char title[TITLE_CHAR_SIZE]
                          ^
      ------------------------------------------------------------

      mudpy/mud_friendly_wrapper.pyx:399:20: Not allowed in a constant expression

Effectively, cython expected a constant in the array declaration, but by using cdef the variable is no longer constant. One possibility is that a different type of array is used. I hope not though, that would be quite a pain. For now I'm shelving this until it becomes a problem, hopefully some other solution is present by then.

rmlmcfadden commented 8 months ago

I agree - none of the suggestions (apart from reverting the hard-coded values) seem to work as drop-in replacements.

Waiting on a better solution sounds good.