# object

The maci data object is a custom data type that provides unique functionality to perform useful operations on attribute names in the object and is responsible for holding all stored data during the runtime of the code.

*Type name representation:*  MaciDataObj

### building a maci data object

To build a maci data object in code, you may run the simple build function (See [maci.build](https://docs.macilib.org/docs/maci/functions/maci.build)). This will return an empty maci object.<br>

*Example creating an empty maci data object using the* [*maci build function*](https://docs.macilib.org/docs/maci/functions/maci.build)

```python
data = maci.build()
```

### creating and setting attribute names with data

Whether loaded from a file (See [maci.load](https://docs.macilib.org/docs/maci/functions/maci.load)) or in code, you can create and set attribute names and assign data to them on the object in code like you normally would expect in python.<br>

*Example creating and setting attributes names in code with basic data*

```python
data.attr1 = 1
data.attr2 = 2
data.attr3 = 3
```

See [maci.load](https://docs.macilib.org/docs/maci/functions/maci.load) and [language section](https://docs.macilib.org/docs/maci/language) for loading data from a file

### object view

You may view the representation of the object by printing the object directly, or calling the [str()](https://docs.python.org/3.12/library/stdtypes.html#str) or [repr()](https://docs.python.org/3.12/library/functions.html#repr) functions on the object. The resulting output will display all attribute names and their currently assigned values.\
\
\&#xNAN;*Example output showing current attribute names and their respective data*

```python
MaciDataObj(attr1=1, attr2=2, attr3=3)
```

If the object is empty, it will show like so:

```python
MaciDataObj()
```

### object operators and built-in behavior

*maci version 1.0.0*

#### equality

Compare maci objects to each other to check for equality. This will check if the data attribute names and values inside the object are exactly the same. Does not check value identity.

*Example comparing maci objects*

```python
maci_obj1 == maci_obj2
```

#### bool

Call the bool built-in function on the object to check if the object is empty or not. Empty means no defined attribute names and values.

*Example calling built-in bool function on maci object*

```python
bool(maci_obj)
```

*Added in maci version 1.1.1*

#### hashability

maci objects are hashable and may be used as keys in data structures as an example. The hash is uniquely generated once per object instance lifetime, and you may modify the object without the hash changing. This allows more flexibility to interconnect maci objects and still update them.

*Example using maci object as key in dict*

```python
dict_data[maci_obj]
```

#### length

Call the len built-in function on the maci object to get the current length of it. Length is the count of how many attribute names have been defined.

*Example calling built-in len function on maci object*

```python
len(maci_obj)
```

### object methods

Perform varying operations on the attribute names or data for the object using the built-in methods. \
\
You can set attribute names to be locked like a constant, or map attribute names to another like a pointer, get views of the object data and their states, and more.&#x20;

See the object's api [methods section](https://docs.macilib.org/docs/maci/object/methods) for all useful functionality

### object hinting

*maci version 1.0.0*

Typing for the MaciDataObj is currently supported if needed for type checkers. This is being currently tested using [mypy](https://www.mypy-lang.org/) for type safety. Updates may be made in the future for uncaught scenarios that is not passing mypy or other type checkers.&#x20;

Conveniently, you can access the MaciDataObj type to hint it in your code from the maci module.

*Example accessing the MaciDataObj type for hinting*

```python
maci.hint.MaciDataObj
```

See [hints section](https://docs.macilib.org/docs/maci/hints) for more on this and other types


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.macilib.org/docs/maci/object.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
