def attribute(self, v, attr, t, boxed = False):
    if attr == "data":
      if boxed:
        self.check_array(v)
        struct_type = self.to_ctype(t)
        ptr_type = type_mappings.to_ctype(t) 
        data_field = "(%s) PyArray_DATA(((PyArrayObject*) %s))" % (ptr_type, v) 
        # get the data field but also fill the base object 
        return self.fresh_var(struct_type, "data", "{%s, %s}" % (data_field, v))
      else:
        return "%s.data" % v  
    elif attr == "shape":
      shape_name = self.fresh_name("shape")
      elt_types = t.elt_types
      n = len(elt_types)
      elt_t = elt_types[0]  
      if boxed:
        self.check_array(v)
        
        assert all(t == elt_t for t in elt_types)

        shape_array = "PyArray_DIMS( (PyArrayObject*) %s)" % v
        self.append("npy_intp* %s = %s;" % (shape_name, shape_array))
      else:
        self.append("npy_intp* %s = %s.shape;" % (shape_name, v))
      return self.array_to_tuple(shape_name, n, elt_t)
      
    elif attr == "strides":
      elt_types = t.elt_types
      n = len(elt_types)  
      elt_t = elt_types[0]
      if boxed:
        assert False, "Can't directly use NumPy strides without dividing by itemsize"
      else:
        strides_name = self.fresh_var("npy_intp*", "strides", "%s.strides" % v)
      return self.array_to_tuple(strides_name, n, elt_t)
    elif attr == 'offset':
      if boxed:
        return "0"
      else:
        return "%s.offset" % v
    elif attr in ('size', 'nelts'):
      if boxed:
        return "PyArray_Size(%s)" % v
      else:
        return "%s.size" % v
       
    elif attr in ('start', 'stop', 'step') or attr.startswith("elt"):
      if boxed:
        self.check_slice(v)
        obj = "((PySliceObject*)%s)->%s" % (v, attr)
        return self.unbox_scalar(obj, t, attr)
      else:
        return "%s.%s" % (v, attr)
    else:
      assert False, "Unsupported attribute %s" % attr
dataset/ETHPy150Open iskandr/parakeet/parakeet/c_backend/pymodule_compiler.py/PyModuleCompiler.attribute/original