# uproot.WritableBranch

Defined in [uproot.writing.writable](https://github.com/scikit-hep/uproot5/blob/db953cf9827349b3d24eb6742404158c1dfd5481/src/uproot/writing/writable.py) on [line 2821](https://github.com/scikit-hep/uproot5/blob/db953cf9827349b3d24eb6742404158c1dfd5481/src/uproot/writing/writable.py#L2821).

### *class* uproot.writing.writable.WritableBranch(tree, datum)

Represents a TBranch from a [uproot.WritableTree](uproot.writing.writable.WritableTree.html.md).

This object exists only to be able to assign compression settings differently
on each TBranch:

```python
my_directory["tree"]["branch1"].compression = uproot.ZLIB(1)
my_directory["tree"]["branch2"].compression = uproot.LZMA(9)
```

Note that compression settings on all TBranches can be set through
uproot.writing.writable.WritableTree.compression:

```python
my_directory["tree"].compression = {"branch1": uproot.ZLIB(1),
                                    "branch2": uproot.LZMA(9)}
```

<a id="uproot-writing-writable-writablebranch-type"></a>

## type

#### WritableBranch.type

The type used to initialize this TBranch.

<a id="uproot-writing-writable-writablebranch-compression"></a>

## compression

#### WritableBranch.compression

Compression algorithm and level ([uproot.compression.Compression](uproot.compression.Compression.html.md) or None)
for new TBaskets added to the TBranch.

This property can be changed and doesn’t have to be the same as the compression
of the file or the rest of the TTree, which allows you to write different objects
with different compression settings.

The following are equivalent:

```python
my_directory["tree"]["branch1"].compression = uproot.ZLIB(1)
my_directory["tree"]["branch2"].compression = uproot.LZMA(9)
```

and

```python
my_directory["tree"].compression = {"branch1": uproot.ZLIB(1),
                                    "branch2": uproot.LZMA(9)}
```
