Skip to content

Commit 849bf3a

Browse files
Michael-J-Wardemgeee
authored andcommitted
add section to the contributor guide on separating python and rust code (apache#860)
1 parent 11b9dd3 commit 849bf3a

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

docs/source/contributor-guide/introduction.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,17 @@ Our pre-commit hooks can be installed by running :code:`pre-commit install`, whi
7171

7272
The pre-commit hooks can also be run adhoc without installing them by simply running :code:`pre-commit run --all-files`
7373

74+
Guidelines for Separating Python and Rust Code
75+
----------------------------------------------
76+
77+
Version 40 of ``datafusion-python`` introduced ``python`` wrappers around the ``pyo3`` generated code to vastly improve the user experience. (See the `blog post <https://datafusion.apache.org/blog/2024/08/20/python-datafusion-40.0.0/>`_ and `pull request <https://github.com/apache/datafusion-python/pull/750>`_ for more details.)
78+
79+
Mostly, the ``python`` code is limited to pure wrappers with type hints and good docstrings, but there are a few reasons for when the code does more:
80+
81+
1. Trivial aliases like :py:func:`~datafusion.functions.array_append` and :py:func:`~datafusion.functions.list_append`.
82+
2. Simple type conversion, like from a ``path`` to a ``string`` of the path or from ``number`` to ``lit(number)``.
83+
3. The additional code makes an API **much** more pythonic, like we do for :py:func:`~datafusion.functions.named_struct` (see `source code <https://github.com/apache/datafusion-python/blob/a0913c728f5f323c1eb4913e614c9d996083e274/python/datafusion/functions.py#L1040-L1046>`_).
84+
7485

7586
Update Dependencies
7687
-------------------

0 commit comments

Comments
 (0)