# Type introspection?

**URL:** <https://forum.tiledb.com/t/type-introspection/115>\
**Category:** Uncategorized\
**Created:** [October 23, 2019, 5:29pm UTC](https://forum.tiledb.com/t/type-introspection/115 "2019-10-23T17:29:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bruce\_Martin](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.tiledb.com/bruce_martin/32/36_2.png) [@Bruce\_Martin](https://forum.tiledb.com/u/Bruce_Martin)\
**Post date:** [October 23, 2019, 5:29pm UTC](https://forum.tiledb.com/t/type-introspection/115/1 "2019-10-23T17:29:35Z")

</div>

The collection/group API has some very basic introspection via `tiledb.object_type()` (in Python). Is there a means to perform further introspection, in particular:

- determine if an array is sparse or dense
- access schema properties (eg, attribute names and types)  
etc?

Or does the current API require that the application code remember the schema of any given object?

---

<div class="post-metadata">

**Author:** ![stavros](https://avatars.discourse-cdn.com/v4/letter/s/51bf81/32.png) [@stavros](https://forum.tiledb.com/u/stavros)\
**Post date:** [October 23, 2019, 5:34pm UTC](https://forum.tiledb.com/t/type-introspection/115/2 "2019-10-23T17:34:37Z")

</div>

You can introspect an array by reading its array schema. In TileDB-Py:  
[https://docs.tiledb.io/projects/tiledb-py/en/latest/python-api.html#tiledb.libtiledb.Array.schema](https://docs.tiledb.io/projects/tiledb-py/en/latest/python-api.html#tiledb.libtiledb.Array.schema)  
[https://docs.tiledb.io/projects/tiledb-py/en/latest/python-api.html#array-schema](https://docs.tiledb.io/projects/tiledb-py/en/latest/python-api.html#array-schema)

New docs are coming up soon, so hopefully it will be easier to find this information 🙂.

---

<div class="post-metadata">

**Author:** ![seth](https://avatars.discourse-cdn.com/v4/letter/s/f14d63/32.png) [@seth](https://forum.tiledb.com/u/seth)\
**Post date:** [October 23, 2019, 5:41pm UTC](https://forum.tiledb.com/t/type-introspection/115/3 "2019-10-23T17:41:58Z")

</div>

A quick example usage of opening the array and accessing the schema and printing the domain:

```auto
with tiledb.SparseArray("s3://mybucket/myarray") as A:
  schema = A.schema
  domain = schema.domain
  print(domain)

```

---

<div class="post-metadata">

**Author:** ![Bruce\_Martin](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.tiledb.com/bruce_martin/32/36_2.png) [@Bruce\_Martin](https://forum.tiledb.com/u/Bruce_Martin)\
**Post date:** [October 23, 2019, 6:34pm UTC](https://forum.tiledb.com/t/type-introspection/115/4 "2019-10-23T18:34:25Z")

</div>

Thank you!

If there is no a priori knowledge of sparse/dense format, does the Array class support schema access, ie, is this legal? (it seems to work, but the docs suggest it might not work)

```auto
with tiledb.Array('path') as A:
    my_array_is_sparse = A.schema.sparse

```

---

<div class="post-metadata">

**Author:** ![stavros](https://avatars.discourse-cdn.com/v4/letter/s/51bf81/32.png) [@stavros](https://forum.tiledb.com/u/stavros)\
**Post date:** [October 23, 2019, 6:52pm UTC](https://forum.tiledb.com/t/type-introspection/115/5 "2019-10-23T18:52:14Z")

</div>

Yeah, that should work.
