| 470 | self.name = name |
| 471 | |
| 472 | def subclass_init(self, cls: type[HasTraits]) -> None: |
| 473 | # Instead of HasDescriptors.setup_instance calling |
| 474 | # every instance_init, we opt in by default. |
| 475 | # This gives descriptors a change to opt out for |
| 476 | # performance reasons. |
| 477 | # Because most traits do not need instance_init, |
| 478 | # and it will otherwise be called for every HasTrait instance |
| 479 | # being created, this otherwise gives a significant performance |
| 480 | # pentalty. Most TypeTraits in traitlets opt out. |
| 481 | cls._instance_inits.append(self.instance_init) |
| 482 | |
| 483 | def instance_init(self, obj: t.Any) -> None: |
| 484 | """Part of the initialization which may depend on the underlying |