# Numba in a class: TypingError: non-precise type pyobject

**URL:** <https://numba.discourse.group/t/numba-in-a-class-typingerror-non-precise-type-pyobject/2833>\
**Category:** Support: How do I do ...?\
**Created:** [December 4, 2024, 10:35pm UTC](https://numba.discourse.group/t/numba-in-a-class-typingerror-non-precise-type-pyobject/2833 "2024-12-04T22:35:29Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![DannyWeitekamp](https://yyz2.discourse-cdn.com/free1/user_avatar/numba.discourse.group/dannyweitekamp/32/144_2.png) [@DannyWeitekamp](https://numba.discourse.group/u/DannyWeitekamp)\
**Post date:** [December 8, 2024, 1:39am UTC](https://numba.discourse.group/t/numba-in-a-class-typingerror-non-precise-type-pyobject/2833/5 "2024-12-08T01:39:34Z")

</div>

> [@Exposing StructRef method to Python side](https://numba.discourse.group/t/exposing-structref-method-to-python-side/1893/4):
>
> What you have looks pretty reasonable to me. @DannyWeitekamp’s [CRE](https://github.com/DannyWeitekamp/Cognitive-Rule-Engine) contains an absolute trove of great examples, including a structref generator that I used as a starting point for my own generator.

Perhaps the trick in this thread (4th post) of allocating the object with “new” instead of using the constructor, and then setting each attribute of the object might work. Or you could just call the constructor directly in your method. Note 1) that the linked example uses structref instead of jitclass, I don’t recall if there is a different special new() for jitclass, you can check the jitclass source 2) if you don’t set every attribute when you do this approach then it is possible to have uninitialized values in the object that have undefined behavior.

---

_[View the full topic](https://numba.discourse.group/t/numba-in-a-class-typingerror-non-precise-type-pyobject/2833)._
