Skip to content

Commit

Permalink
move statics into to_object bodies
Browse files Browse the repository at this point in the history
  • Loading branch information
mhils committed Jun 1, 2023
1 parent 2ee012c commit c6105ad
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/conversions/std/ipaddr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ impl GILOnceCell<Py<PyType>> {
}
}

static IPV4_ADDRESS: GILOnceCell<Py<PyType>> = GILOnceCell::new();
static IPV6_ADDRESS: GILOnceCell<Py<PyType>> = GILOnceCell::new();

impl FromPyObject<'_> for IpAddr {
fn extract(obj: &PyAny) -> PyResult<Self> {
match obj.getattr(intern!(obj.py(), "packed")) {
Expand All @@ -42,6 +39,7 @@ impl FromPyObject<'_> for IpAddr {

impl ToPyObject for Ipv4Addr {
fn to_object(&self, py: Python<'_>) -> PyObject {
static IPV4_ADDRESS: GILOnceCell<Py<PyType>> = GILOnceCell::new();
IPV4_ADDRESS
.get_or_try_init_type_ref(py, "ipaddress", "IPv4Address")
.expect("failed to load ipaddress.IPv4Address")
Expand All @@ -53,6 +51,7 @@ impl ToPyObject for Ipv4Addr {

impl ToPyObject for Ipv6Addr {
fn to_object(&self, py: Python<'_>) -> PyObject {
static IPV6_ADDRESS: GILOnceCell<Py<PyType>> = GILOnceCell::new();
IPV6_ADDRESS
.get_or_try_init_type_ref(py, "ipaddress", "IPv6Address")
.expect("failed to load ipaddress.IPv6Address")
Expand Down

0 comments on commit c6105ad

Please sign in to comment.