From d4c359aa2924900336dede9cc916d276e9a0c7f3 Mon Sep 17 00:00:00 2001 From: Christian Lorentzen Date: Sun, 21 Apr 2024 14:39:50 +0200 Subject: [PATCH 1/2] DOC document cython typedefs --- doc/developers/cython.rst | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/doc/developers/cython.rst b/doc/developers/cython.rst index e98501879d50e..6edcce341ec70 100644 --- a/doc/developers/cython.rst +++ b/doc/developers/cython.rst @@ -141,3 +141,16 @@ must be ``cimported`` from this module and not from the OpenMP library directly: The parallel loop, `prange`, is already protected by cython and can be used directly from `cython.parallel`. + +Types +~~~~~ + +Cython code requires to use explicit types. This is one of the reasons to get good +performance boosts. In order to avoid code duplication, we have a central place +for the most used types in +`sklearn/utils/_typedefs.pyd `_. +Ideally you start by having a look there and simpliy `cimport`, for example + +.. code-block:: cython + + from sklear.utils._typedefs cimport float32, float64 From d77bf0f4869c7809d6b766b7b1145fea3a93445a Mon Sep 17 00:00:00 2001 From: Christian Lorentzen Date: Mon, 22 Apr 2024 12:24:40 +0200 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Tim Head --- doc/developers/cython.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/developers/cython.rst b/doc/developers/cython.rst index 6edcce341ec70..82022ddcbcc56 100644 --- a/doc/developers/cython.rst +++ b/doc/developers/cython.rst @@ -145,11 +145,11 @@ from `cython.parallel`. Types ~~~~~ -Cython code requires to use explicit types. This is one of the reasons to get good -performance boosts. In order to avoid code duplication, we have a central place +Cython code requires to use explicit types. This is one of the reasons you get a +performance boost. In order to avoid code duplication, we have a central place for the most used types in `sklearn/utils/_typedefs.pyd `_. -Ideally you start by having a look there and simpliy `cimport`, for example +Ideally you start by having a look there and `cimport` types you need, for example .. code-block:: cython