@@ -75,7 +75,7 @@ fn hamming_distance_string(py: Python<'_>, a: &str, b: &str) -> PyResult<u64> {
7575 // release the GIL so other Python threads can run during the computation.
7676 let a_owned = a_bytes. to_vec ( ) ;
7777 let b_owned = b_bytes. to_vec ( ) ;
78- py. allow_threads ( move || hamming_distance_string_dispatch ( & a_owned, & b_owned) )
78+ py. detach ( move || hamming_distance_string_dispatch ( & a_owned, & b_owned) )
7979 . map_err ( PyValueError :: new_err)
8080}
8181
@@ -114,7 +114,7 @@ fn hamming_distance_bytes(
114114 let result = if a_slice. len ( ) < GIL_RELEASE_THRESHOLD {
115115 hamming_distance_bytes_dispatch ( a_slice, b_slice, -1 )
116116 } else {
117- py. allow_threads ( move || hamming_distance_bytes_dispatch ( a_slice, b_slice, -1 ) )
117+ py. detach ( move || hamming_distance_bytes_dispatch ( a_slice, b_slice, -1 ) )
118118 } ;
119119 drop ( buf_a) ;
120120 drop ( buf_b) ;
@@ -242,8 +242,7 @@ fn check_bytes_within_dist(
242242 return Err ( PyValueError :: new_err ( "array sizes need to be the same" ) ) ;
243243 }
244244
245- let result =
246- py. allow_threads ( move || hamming_distance_bytes_dispatch ( a_slice, b_slice, max_dist) ) ;
245+ let result = py. detach ( move || hamming_distance_bytes_dispatch ( a_slice, b_slice, max_dist) ) ;
247246 drop ( buf_a) ;
248247 drop ( buf_b) ;
249248 Ok ( result != u64:: MAX )
@@ -296,7 +295,7 @@ fn check_bytes_arrays_first_within_dist(
296295 ) ) ;
297296 }
298297
299- let result = py. allow_threads ( move || {
298+ let result = py. detach ( move || {
300299 // Delegate to the serial early-exit implementation. `first` is never
301300 // parallelized: a parallel scan must evaluate every element to find the
302301 // minimum matching index, which is far slower for early/common matches.
@@ -343,7 +342,7 @@ fn check_bytes_arrays_best_within_dist(
343342 ) ) ;
344343 }
345344
346- let result = py. allow_threads ( move || {
345+ let result = py. detach ( move || {
347346 // Delegate to the rayon-parallel implementation (serial below
348347 // PAR_THRESHOLD_BYTES). Tie-break (lowest distance, then lowest index)
349348 // matches the previous serial behavior.
@@ -389,7 +388,7 @@ fn check_bytes_arrays_all_within_dist(
389388 ) ) ;
390389 }
391390
392- let results = py. allow_threads ( move || {
391+ let results = py. detach ( move || {
393392 // Delegate to the rayon-parallel implementation (serial below
394393 // PAR_THRESHOLD_BYTES). Results are returned in ascending index order.
395394 crate :: bytes_array_all_within_dist ( big_slice, small_slice, max_dist)
0 commit comments