fn extract(ob: &'a PyAny) -> PyResult<Self> {
        let array = unsafe {
            if npyffi::PyArray_Check(ob.as_ptr()) == 0 {
                return Err(PyDowncastError::new(ob, "PyArray<T, D>").into());
            }
            &*(ob as *const PyAny as *const PyArray<T, D>)
        };
        let dtype = array.dtype();
        let dim = array.shape().len();
        if T::is_same_type(dtype) && D::NDIM.map(|n| n == dim).unwrap_or(true) {
            Ok(array)
        } else {
            Err(ShapeError::new(dtype, dim, T::DATA_TYPE, D::NDIM).into())
        }
    }
// here we do type-check three times
// 1. Checks if the object is PyArray
// 2. Checks if the data type of the array is T
// 3. Checks if the dimension is same as D
here we do type-check three times
1. Checks if the object is PyArray
2. Checks if the data type of the array is T
3. Checks if the dimension is same as D
here we do type - check three times 1 . Checks if the object is PyArray 2 . Checks if the data type of the array is T 3 . Checks if the dimension is same as D
fn extract(ob: &'a PyAny) -> PyResult<Self> {
        let array = unsafe {
            if npyffi::PyArray_Check(ob.as_ptr()) == 0 {
                return Err(PyDowncastError::new(ob, "PyArray<T, D>").into());
            }
            &*(ob as *const PyAny as *const PyArray<T, D>)
        };
        let dtype = array.dtype();
        let dim = array.shape().len();
        if T::is_same_type(dtype) && D::NDIM.map(|n| n == dim).unwrap_or(true) {
            Ok(array)
        } else {
            Err(ShapeError::new(dtype, dim, T::DATA_TYPE, D::NDIM).into())
        }
    }
fn extract ( ob : & ' a PyAny ) -> PyResult < Self > { let array = unsafe { if npyffi :: PyArray_Check ( ob . as_ptr ( ) ) == 0 { return Err ( PyDowncastError :: new ( ob , " " ) . into ( ) ) ; } & * ( ob as * const PyAny as * const PyArray < T , D > ) } ; let dtype = array . dtype ( ) ; let dim = array . shape ( ) . len ( ) ; if T :: is_same_type ( dtype ) && D :: NDIM . map ( | n | n == dim ) . unwrap_or ( true ) { Ok ( array ) } else { Err ( ShapeError :: new ( dtype , dim , T :: DATA_TYPE , D :: NDIM ) . into ( ) ) } }
here we do type-check three times
1.
here we do type - check three times 1 .
ob
&'a PyAny