Skip to content

Commit ec36489

Browse files
authored
Merge pull request RustPython#4293 from discord9/update_crossbeam
depend: Update crossbeam-utils to "0.8.9" instead of "=0.8.9"
2 parents 1a13dd9 + e53693b commit ec36489

File tree

20 files changed

+611
-408
lines changed

20 files changed

+611
-408
lines changed

Cargo.lock

Lines changed: 522 additions & 343 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

stdlib/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ num-bigint = "0.4.3"
5555
num-integer = "0.1.44"
5656
num-rational = "0.4.1"
5757

58-
crossbeam-utils = "=0.8.9"
58+
crossbeam-utils = "0.8.9"
5959
itertools = "0.10.3"
6060
lexical-parse-float = "0.8.3"
6161
num-traits = "0.2.14"
@@ -73,11 +73,11 @@ libz-sys = { version = "1.1.5", optional = true }
7373
num_enum = "0.5.7"
7474
ascii = "1.0.0"
7575
parking_lot = "0.12.0"
76+
once_cell = "1.13.0"
7677

7778
# uuid
7879
[target.'cfg(not(any(target_os = "ios", target_os = "android", target_os = "windows", target_arch = "wasm32")))'.dependencies]
7980
mac_address = "1.1.3"
80-
once_cell = "1.13.0"
8181
uuid = { version = "1.1.2", features = ["v1", "fast-rng", "macro-diagnostics"] }
8282

8383
# mmap

stdlib/src/mmap.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,8 @@ mod mmap {
446446

447447
impl AsSequence for PyMmap {
448448
fn as_sequence() -> &'static PySequenceMethods {
449-
static AS_SEQUENCE: PySequenceMethods = PySequenceMethods {
449+
use once_cell::sync::Lazy;
450+
static AS_SEQUENCE: Lazy<PySequenceMethods> = Lazy::new(|| PySequenceMethods {
450451
length: atomic_func!(|seq, _vm| Ok(PyMmap::sequence_downcast(seq).len())),
451452
item: atomic_func!(|seq, i, vm| {
452453
let zelf = PyMmap::sequence_downcast(seq);
@@ -462,7 +463,7 @@ mod mmap {
462463
}
463464
}),
464465
..PySequenceMethods::NOT_IMPLEMENTED
465-
};
466+
});
466467
&AS_SEQUENCE
467468
}
468469
}

vm/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ is-macro = "0.2.0"
5656
result-like = "0.4.5"
5757
num_enum = "0.5.7"
5858
bstr = "0.2.17"
59-
crossbeam-utils = "=0.8.9"
59+
crossbeam-utils = "0.8.9"
6060
parking_lot = "0.12.0"
6161
thread_local = "1.1.4"
6262
cfg-if = "1.0.0"

vm/src/builtins/bytes.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ use crate::{
2626
TryFromBorrowedObject, TryFromObject, VirtualMachine,
2727
};
2828
use bstr::ByteSlice;
29+
use once_cell::sync::Lazy;
2930
use std::{mem::size_of, ops::Deref};
3031

3132
#[pyclass(module = false, name = "bytes")]
@@ -572,20 +573,20 @@ impl AsBuffer for PyBytes {
572573

573574
impl AsMapping for PyBytes {
574575
fn as_mapping() -> &'static PyMappingMethods {
575-
static AS_MAPPING: PyMappingMethods = PyMappingMethods {
576+
static AS_MAPPING: Lazy<PyMappingMethods> = Lazy::new(|| PyMappingMethods {
576577
length: atomic_func!(|mapping, _vm| Ok(PyBytes::mapping_downcast(mapping).len())),
577578
subscript: atomic_func!(
578579
|mapping, needle, vm| PyBytes::mapping_downcast(mapping)._getitem(needle, vm)
579580
),
580581
..PyMappingMethods::NOT_IMPLEMENTED
581-
};
582+
});
582583
&AS_MAPPING
583584
}
584585
}
585586

586587
impl AsSequence for PyBytes {
587588
fn as_sequence() -> &'static PySequenceMethods {
588-
static AS_SEQUENCE: PySequenceMethods = PySequenceMethods {
589+
static AS_SEQUENCE: Lazy<PySequenceMethods> = Lazy::new(|| PySequenceMethods {
589590
length: atomic_func!(|seq, _vm| Ok(PyBytes::sequence_downcast(seq).len())),
590591
concat: atomic_func!(|seq, other, vm| {
591592
PyBytes::sequence_downcast(seq)
@@ -612,21 +613,21 @@ impl AsSequence for PyBytes {
612613
PyBytes::sequence_downcast(seq).contains(other, vm)
613614
}),
614615
..PySequenceMethods::NOT_IMPLEMENTED
615-
};
616+
});
616617
&AS_SEQUENCE
617618
}
618619
}
619620

620621
impl AsNumber for PyBytes {
621622
fn as_number() -> &'static PyNumberMethods {
622-
static AS_NUMBER: PyNumberMethods = PyNumberMethods {
623+
static AS_NUMBER: Lazy<PyNumberMethods> = Lazy::new(|| PyNumberMethods {
623624
remainder: atomic_func!(|number, other, vm| {
624625
PyBytes::number_downcast(number)
625626
.mod_(other.to_owned(), vm)
626627
.to_pyresult(vm)
627628
}),
628629
..PyNumberMethods::NOT_IMPLEMENTED
629-
};
630+
});
630631
&AS_NUMBER
631632
}
632633
}

vm/src/builtins/complex.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use crate::{
1515
};
1616
use num_complex::Complex64;
1717
use num_traits::Zero;
18+
use once_cell::sync::Lazy;
1819
use rustpython_common::{float_ops, hash};
1920
use std::num::Wrapping;
2021

@@ -447,7 +448,7 @@ impl Hashable for PyComplex {
447448

448449
impl AsNumber for PyComplex {
449450
fn as_number() -> &'static PyNumberMethods {
450-
static AS_NUMBER: PyNumberMethods = PyNumberMethods {
451+
static AS_NUMBER: Lazy<PyNumberMethods> = Lazy::new(|| PyNumberMethods {
451452
add: atomic_func!(|number, other, vm| PyComplex::number_complex_op(
452453
number,
453454
other,
@@ -481,7 +482,7 @@ impl AsNumber for PyComplex {
481482
PyComplex::number_general_op(number, other, inner_div, vm)
482483
}),
483484
..PyNumberMethods::NOT_IMPLEMENTED
484-
};
485+
});
485486
&AS_NUMBER
486487
}
487488
}

vm/src/builtins/dict.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ use crate::{
2626
vm::VirtualMachine,
2727
AsObject, Context, Py, PyObject, PyObjectRef, PyPayload, PyRef, PyResult, TryFromObject,
2828
};
29+
use once_cell::sync::Lazy;
2930
use rustpython_common::lock::PyMutex;
3031
use std::fmt;
3132

@@ -465,12 +466,12 @@ impl AsMapping for PyDict {
465466

466467
impl AsSequence for PyDict {
467468
fn as_sequence() -> &'static PySequenceMethods {
468-
static AS_SEQUENCE: PySequenceMethods = PySequenceMethods {
469+
static AS_SEQUENCE: Lazy<PySequenceMethods> = Lazy::new(|| PySequenceMethods {
469470
contains: atomic_func!(|seq, target, vm| PyDict::sequence_downcast(seq)
470471
.entries
471472
.contains(vm, target)),
472473
..PySequenceMethods::NOT_IMPLEMENTED
473-
};
474+
});
474475
&AS_SEQUENCE
475476
}
476477
}
@@ -1052,7 +1053,7 @@ impl Comparable for PyDictKeys {
10521053

10531054
impl AsSequence for PyDictKeys {
10541055
fn as_sequence() -> &'static PySequenceMethods {
1055-
static AS_SEQUENCE: PySequenceMethods = PySequenceMethods {
1056+
static AS_SEQUENCE: Lazy<PySequenceMethods> = Lazy::new(|| PySequenceMethods {
10561057
length: atomic_func!(|seq, _vm| Ok(PyDictKeys::sequence_downcast(seq).len())),
10571058
contains: atomic_func!(|seq, target, vm| {
10581059
PyDictKeys::sequence_downcast(seq)
@@ -1061,7 +1062,7 @@ impl AsSequence for PyDictKeys {
10611062
.contains(vm, target)
10621063
}),
10631064
..PySequenceMethods::NOT_IMPLEMENTED
1064-
};
1065+
});
10651066
&AS_SEQUENCE
10661067
}
10671068
}
@@ -1108,7 +1109,7 @@ impl Comparable for PyDictItems {
11081109

11091110
impl AsSequence for PyDictItems {
11101111
fn as_sequence() -> &'static PySequenceMethods {
1111-
static AS_SEQUENCE: PySequenceMethods = PySequenceMethods {
1112+
static AS_SEQUENCE: Lazy<PySequenceMethods> = Lazy::new(|| PySequenceMethods {
11121113
length: atomic_func!(|seq, _vm| Ok(PyDictItems::sequence_downcast(seq).len())),
11131114
contains: atomic_func!(|seq, target, vm| {
11141115
PyDictItems::sequence_downcast(seq)
@@ -1117,7 +1118,7 @@ impl AsSequence for PyDictItems {
11171118
.contains(vm, target)
11181119
}),
11191120
..PySequenceMethods::NOT_IMPLEMENTED
1120-
};
1121+
});
11211122
&AS_SEQUENCE
11221123
}
11231124
}
@@ -1133,10 +1134,10 @@ impl Unconstructible for PyDictValues {}
11331134

11341135
impl AsSequence for PyDictValues {
11351136
fn as_sequence() -> &'static PySequenceMethods {
1136-
static AS_SEQUENCE: PySequenceMethods = PySequenceMethods {
1137+
static AS_SEQUENCE: Lazy<PySequenceMethods> = Lazy::new(|| PySequenceMethods {
11371138
length: atomic_func!(|seq, _vm| Ok(PyDictValues::sequence_downcast(seq).len())),
11381139
..PySequenceMethods::NOT_IMPLEMENTED
1139-
};
1140+
});
11401141
&AS_SEQUENCE
11411142
}
11421143
}

vm/src/builtins/float.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use num_bigint::{BigInt, ToBigInt};
2121
use num_complex::Complex64;
2222
use num_rational::Ratio;
2323
use num_traits::{Signed, ToPrimitive, Zero};
24+
use once_cell::sync::Lazy;
2425

2526
#[pyclass(module = false, name = "float")]
2627
#[derive(Debug, Copy, Clone, PartialEq)]
@@ -549,7 +550,7 @@ impl Hashable for PyFloat {
549550

550551
impl AsNumber for PyFloat {
551552
fn as_number() -> &'static PyNumberMethods {
552-
static AS_NUMBER: PyNumberMethods = PyNumberMethods {
553+
static AS_NUMBER: Lazy<PyNumberMethods> = Lazy::new(|| PyNumberMethods {
553554
add: atomic_func!(|num, other, vm| PyFloat::number_float_op(
554555
num,
555556
other,
@@ -602,7 +603,7 @@ impl AsNumber for PyFloat {
602603
PyFloat::number_general_op(num, other, inner_div, vm)
603604
}),
604605
..PyNumberMethods::NOT_IMPLEMENTED
605-
};
606+
});
606607
&AS_NUMBER
607608
}
608609
}

vm/src/builtins/genericalias.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use once_cell::sync::Lazy;
2+
13
use super::type_;
24
use crate::{
35
atomic_func,
@@ -320,12 +322,12 @@ pub fn subs_parameters<F: Fn(&VirtualMachine) -> PyResult<String>>(
320322

321323
impl AsMapping for PyGenericAlias {
322324
fn as_mapping() -> &'static PyMappingMethods {
323-
static AS_MAPPING: PyMappingMethods = PyMappingMethods {
325+
static AS_MAPPING: Lazy<PyMappingMethods> = Lazy::new(|| PyMappingMethods {
324326
subscript: atomic_func!(|mapping, needle, vm| {
325327
PyGenericAlias::mapping_downcast(mapping).getitem(needle.to_owned(), vm)
326328
}),
327329
..PyMappingMethods::NOT_IMPLEMENTED
328-
};
330+
});
329331
&AS_MAPPING
330332
}
331333
}

vm/src/builtins/int.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use num_bigint::{BigInt, BigUint, Sign};
2020
use num_integer::Integer;
2121
use num_rational::Ratio;
2222
use num_traits::{One, Pow, PrimInt, Signed, ToPrimitive, Zero};
23+
use once_cell::sync::Lazy;
2324
use std::ops::{Div, Neg};
2425
use std::{fmt, ops::Not};
2526

@@ -728,7 +729,7 @@ impl Hashable for PyInt {
728729

729730
impl AsNumber for PyInt {
730731
fn as_number() -> &'static PyNumberMethods {
731-
static AS_NUMBER: PyNumberMethods = PyNumberMethods {
732+
static AS_NUMBER: Lazy<PyNumberMethods> = Lazy::new(|| PyNumberMethods {
732733
add: atomic_func!(|num, other, vm| PyInt::number_int_op(num, other, |a, b| a + b, vm)),
733734
subtract: atomic_func!(|num, other, vm| PyInt::number_int_op(
734735
num,
@@ -794,7 +795,7 @@ impl AsNumber for PyInt {
794795
}),
795796
index: atomic_func!(|num, vm| Ok(PyInt::number_int(num, vm))),
796797
..PyNumberMethods::NOT_IMPLEMENTED
797-
};
798+
});
798799
&AS_NUMBER
799800
}
800801
}

0 commit comments

Comments
 (0)