From 92749cd5a91f95334ab35a06479ecf6d2e89d0f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jelmer=20Vernoo=C4=B3?= Date: Wed, 7 Aug 2024 13:28:09 +0100 Subject: [PATCH] Refer to Rust rather than C bindings --- CONTRIBUTING.rst | 5 ++--- README.rst | 2 +- docs/performance.txt | 2 +- dulwich/client.py | 5 ++++- dulwich/diff_tree.py | 2 +- dulwich/objects.py | 4 ++-- tests/test_objects.py | 2 +- 7 files changed, 12 insertions(+), 10 deletions(-) diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 2fc0c2979..8dbb1fa20 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -1,7 +1,6 @@ -All functionality should be available in pure Python. Optional C +All functionality should be available in pure Python. Optional Rust implementations may be written for performance reasons, but should never -replace the Python implementation. The C implementations should follow the -kernel/git coding style. +replace the Python implementation. Where possible include updates to NEWS along with your improvements. diff --git a/README.rst b/README.rst index 926141ec7..2abb9de16 100644 --- a/README.rst +++ b/README.rst @@ -16,7 +16,7 @@ in the particular Monty Python sketch. Installation ------------ -By default, Dulwich' setup.py will attempt to build and install the optional C +By default, Dulwich' setup.py will attempt to build and install the optional Rust extensions. The reason for this is that they significantly improve the performance since some low-level operations that are executed often are much slower in CPython. diff --git a/docs/performance.txt b/docs/performance.txt index d2fd817f8..e5c04260c 100644 --- a/docs/performance.txt +++ b/docs/performance.txt @@ -6,6 +6,6 @@ Possible areas for improvement Places for improvement, ordered by difficulty / effectiveness: -* read_zlib() should have a C equivalent (~ 4% overhead atm) +* read_zlib() should have a Rust equivalent (~ 4% overhead atm) * unpack_object() should have a C equivalent diff --git a/dulwich/client.py b/dulwich/client.py index 61dae810d..58b3cadeb 100644 --- a/dulwich/client.py +++ b/dulwich/client.py @@ -1657,7 +1657,10 @@ class LocalGitClient(GitClient): """Git Client that just uses a local on-disk repository.""" def __init__( - self, thin_packs=True, report_activity=None, config: Optional[Config] = None + self, + thin_packs: bool = True, + report_activity=None, + config: Optional[Config] = None, ) -> None: """Create a new LocalGitClient instance. diff --git a/dulwich/diff_tree.py b/dulwich/diff_tree.py index aada776d6..eeec9d48d 100644 --- a/dulwich/diff_tree.py +++ b/dulwich/diff_tree.py @@ -644,7 +644,7 @@ def changes_with_renames( _merge_entries_py = _merge_entries _count_blocks_py = _count_blocks try: - # Try to import C versions + # Try to import Rust versions from dulwich._diff_tree import ( # type: ignore _count_blocks, _is_tree, diff --git a/dulwich/objects.py b/dulwich/objects.py index 27c240138..04e392508 100644 --- a/dulwich/objects.py +++ b/dulwich/objects.py @@ -1020,7 +1020,7 @@ def sorted_tree_items(entries, name_order: bool): key_func = key_entry for name, entry in sorted(entries.items(), key=key_func): mode, hexsha = entry - # Stricter type checks than normal to mirror checks in the C version. + # Stricter type checks than normal to mirror checks in the Rust version. mode = int(mode) if not isinstance(hexsha, bytes): raise TypeError(f"Expected bytes for SHA, got {hexsha!r}") @@ -1666,7 +1666,7 @@ def _get_extra(self): _parse_tree_py = parse_tree _sorted_tree_items_py = sorted_tree_items try: - # Try to import C versions + # Try to import Rust versions from dulwich._objects import parse_tree, sorted_tree_items # type: ignore except ImportError: pass diff --git a/tests/test_objects.py b/tests/test_objects.py index 0d907f1e1..8c6d18f5f 100644 --- a/tests/test_objects.py +++ b/tests/test_objects.py @@ -890,7 +890,7 @@ def do_sort(entries): # C/Python implementations may differ in specific error types, but # should all error on invalid inputs. - # For example, the C implementation has stricter type checks, so may + # For example, the Rust implementation has stricter type checks, so may # raise TypeError where the Python implementation raises # AttributeError. errors = (TypeError, ValueError, AttributeError)