:orphan: |rss_image| **2019-03 - 1/1** :ref:`Blog ` :ref:`machine_learning (5) ` .. |rss_image| image:: feed-icon-16x16.png :target: ../_downloads/rss.xml :alt: RSS ---- .. index:: 2019-03 .. _ap-month-2019-03-0: 2019-03 - 1/1 +++++++++++++ .. blogpostagg:: :title: Nogil, numpy, cython :date: 2019-03-25 :keywords: nogil,numpy,blas,lapack :categories: cython :rawfile: 2019/2019-03-25_nogil.rst I had to implement a custom criterion to optimize a decision tree and I wanted to leverage :epkg:`scikit-learn` instead of rewriting my own. Version 0.21 of :epkg:`scikit-learn` introduced some changed in the API which make possible to overload an existing criterion and replace some of the logic by another one: `_criterion.pyx `_. The purpose was to show that a fast implementation requires some tricks (see :ref:`piecewiselinearregressioncriterionrst`) and `piecewise_tree_regression_criterion.pyx `_, `piecewise_tree_regression_criterion_fast.pyx `_ for the code. Other than that, every function to overlaod is marked as :epkg:`nogil`. Every function or method marked as *nogil* cannot go through the :epkg:`GIL` (see also :epkg:`PEP-0311`), which no :epkg:`python` object can be created in that method. In fact, no :epkg:`python` can be called inside a :epkg:`Cython` method protected with *nogil*. The issue with that is that any :epkg:`numpy` method cannot be called. ... ---- |rss_image| **2019-03 - 1/1** :ref:`2018-05 (1) ` :ref:`2019-02 (4) ` :ref:`2019-03 (1) ` :ref:`2020-09 (1) ` :ref:`2021-01 (1) `