From 4b2f4b3a15743897618c96cec47545b934501089 Mon Sep 17 00:00:00 2001 From: ijl Date: Thu, 16 Jan 2020 13:53:54 +0000 Subject: [PATCH 1/3] Use parking_lot::Mutex instead of spin::Mutex spin is no longer maintained. Fixes #718. --- CHANGELOG.md | 1 + Cargo.toml | 16 ++++++++-------- src/gil.rs | 5 ++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1262cf45..ad86755b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. * The blanket implementations for `FromPyObject` for `&T` and `&mut T` are no longer specializable. Implement `PyTryFrom` for your type to control the behavior of `FromPyObject::extract()` for your types. * The implementation for `IntoPy for T` where `U: FromPy` is no longer specializable. Control the behavior of this via the implementation of `FromPy`. * `#[new]` does not take `PyRawObject` and can reutrn `Self` [#683](https://github.com/PyO3/pyo3/pull/683) +* Use `parking_lot::Mutex` instead of `spin::Mutex` [#734](https://github.com/PyO3/pyo3/pull/734) ### Added diff --git a/Cargo.toml b/Cargo.toml index c41e6017..983ce2d8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,16 +19,16 @@ travis-ci = { repository = "PyO3/pyo3", branch = "master" } appveyor = { repository = "fafhrd91/pyo3" } [dependencies] -libc = "0.2.62" -spin = "0.5.1" -num-traits = "0.2.8" -pyo3cls = { path = "pyo3cls", version = "=0.8.5" } -num-complex = { version = ">= 0.2", optional = true } -num-bigint = { version = ">= 0.2", optional = true } -inventory = "0.1.4" indoc = "0.3.4" -unindent = "0.1.4" +inventory = "0.1.4" +libc = "0.2.62" +num-bigint = { version = ">= 0.2", optional = true } +num-complex = { version = ">= 0.2", optional = true } +num-traits = "0.2.8" +parking_lot = { version = "0.10", features = ["nightly"] } paste = "0.1.6" +pyo3cls = { path = "pyo3cls", version = "=0.8.5" } +unindent = "0.1.4" [dev-dependencies] assert_approx_eq = "1.1.0" diff --git a/src/gil.rs b/src/gil.rs index e56b7eb5..bebbde78 100644 --- a/src/gil.rs +++ b/src/gil.rs @@ -6,7 +6,6 @@ use crate::ffi; use crate::internal_tricks::Unsendable; use crate::types::PyAny; use crate::Python; -use spin; use std::ptr::NonNull; use std::{any, sync}; @@ -124,7 +123,7 @@ struct ReleasePool { borrowed: ArrayList>, pointers: *mut Vec>, obj: Vec>, - p: spin::Mutex<*mut Vec>>, + p: parking_lot::Mutex<*mut Vec>>, } impl ReleasePool { @@ -134,7 +133,7 @@ impl ReleasePool { borrowed: ArrayList::new(), pointers: Box::into_raw(Box::new(Vec::with_capacity(256))), obj: Vec::with_capacity(8), - p: spin::Mutex::new(Box::into_raw(Box::new(Vec::with_capacity(256)))), + p: parking_lot::Mutex::new(Box::into_raw(Box::new(Vec::with_capacity(256)))), } } From a55a48b1893ee7869bbc7714beb1e18633e8ff6a Mon Sep 17 00:00:00 2001 From: ijl Date: Thu, 16 Jan 2020 14:04:17 +0000 Subject: [PATCH 2/3] _PyDict_SetItem_KnownHash() --- src/ffi/dictobject.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ffi/dictobject.rs b/src/ffi/dictobject.rs index 1c8273af..5db462c1 100644 --- a/src/ffi/dictobject.rs +++ b/src/ffi/dictobject.rs @@ -1,5 +1,5 @@ use crate::ffi::object::*; -use crate::ffi::pyport::Py_ssize_t; +use crate::ffi::pyport::{Py_hash_t, Py_ssize_t}; use std::os::raw::{c_char, c_int}; #[cfg_attr(windows, link(name = "pythonXY"))] @@ -68,6 +68,13 @@ extern "C" { pub fn PyDict_GetItemWithError(mp: *mut PyObject, key: *mut PyObject) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyDict_SetItem")] pub fn PyDict_SetItem(mp: *mut PyObject, key: *mut PyObject, item: *mut PyObject) -> c_int; + #[cfg(not(PyPy))] + pub fn _PyDict_SetItem_KnownHash( + mp: *mut PyObject, + key: *mut PyObject, + item: *mut PyObject, + hash: Py_hash_t, + ) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyDict_DelItem")] pub fn PyDict_DelItem(mp: *mut PyObject, key: *mut PyObject) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyDict_Clear")] From 23d380ef07259c253daa9b96d966315f0fb63c9d Mon Sep 17 00:00:00 2001 From: ijl Date: Thu, 16 Jan 2020 14:04:25 +0000 Subject: [PATCH 3/3] _Py_HashBytes() --- src/ffi/pyhash.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ffi/pyhash.rs b/src/ffi/pyhash.rs index 3a57bf2a..175e31e4 100644 --- a/src/ffi/pyhash.rs +++ b/src/ffi/pyhash.rs @@ -20,4 +20,6 @@ impl Default for PyHash_FuncDef { #[cfg_attr(windows, link(name = "pythonXY"))] extern "C" { pub fn PyHash_GetFuncDef() -> *mut PyHash_FuncDef; + #[cfg(not(PyPy))] + pub fn _Py_HashBytes(src: *const c_void, len: Py_ssize_t) -> Py_hash_t; }