NOAA-MDL / grib2io

Python interface to the NCEP G2C Library for reading and writing GRIB2 messages.
https://noaa-mdl.github.io/grib2io
MIT License
33 stars 12 forks source link

Refactor g2clib Cython #156

Open EricEngle-NOAA opened 3 months ago

EricEngle-NOAA commented 3 months ago

The majority of g2clib.pyx has remained untouched from the time of pygrib/ncepgrib2 which then Cython was at version 0.2x. Since then, Cython is now at 3.0. When building grib2io, Cython produces the following dialog.

Just a snippet...

src/ext/g2clib.c:3224:10: warning: 'PyObject_AsWriteBuffer' is deprecated [-Wdeprecated-declarations]
  (void)(PyObject_AsWriteBuffer(__pyx_v_a, (&__pyx_v_abuf), (&__pyx_v_buflen)));
         ^
/Users/ericengle/.pyenv/versions/3.11.9/include/python3.11/abstract.h:353:1: note: 'PyObject_AsWriteBuffer' has been explicitly marked deprecated here
Py_DEPRECATED(3.0)
^
/Users/ericengle/.pyenv/versions/3.11.9/include/python3.11/pyport.h:336:54: note: expanded from macro 'Py_DEPRECATED'
#define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__))
                                                     ^
src/ext/g2clib.c:5601:10: warning: 'PyObject_AsReadBuffer' is deprecated [-Wdeprecated-declarations]
  (void)(PyObject_AsReadBuffer(__pyx_v_drtmpl, (&__pyx_v_drtmpldat), (&__pyx_v_buflen)));
         ^
/Users/ericengle/.pyenv/versions/3.11.9/include/python3.11/abstract.h:342:1: note: 'PyObject_AsReadBuffer' has been explicitly marked deprecated here
Py_DEPRECATED(3.0)
^
/Users/ericengle/.pyenv/versions/3.11.9/include/python3.11/pyport.h:336:54: note: expanded from macro 'Py_DEPRECATED'
#define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__))
                                                     ^
src/ext/g2clib.c:5601:48: warning: passing 'void **' to parameter of type 'const void **' discards qualifiers in nested pointer types [-Wincompatible-pointer-types-discards-qualifiers]
  (void)(PyObject_AsReadBuffer(__pyx_v_drtmpl, (&__pyx_v_drtmpldat), (&__pyx_v_buflen)));
                                               ^~~~~~~~~~~~~~~~~~~~
/Users/ericengle/.pyenv/versions/3.11.9/include/python3.11/abstract.h:344:52: note: passing argument to parameter 'buffer' here
                                      const void **buffer,
                                                   ^
src/ext/g2clib.c:5610:10: warning: 'PyObject_AsReadBuffer' is deprecated [-Wdeprecated-declarations]
  (void)(PyObject_AsReadBuffer(__pyx_v_gdtmpl, (&__pyx_v_gdtmpldat), (&__pyx_v_buflen)));
         ^
/Users/ericengle/.pyenv/versions/3.11.9/include/python3.11/abstract.h:342:1: note: 'PyObject_AsReadBuffer' has been explicitly marked deprecated here
Py_DEPRECATED(3.0)
^
/Users/ericengle/.pyenv/versions/3.11.9/include/python3.11/pyport.h:336:54: note: expanded from macro 'Py_DEPRECATED'
#define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__))

There is a lot of syntax that has been mark a deprecated.

So we need to clean this up. I'd like to think we could possibly see a performance boost too.