how to pass class as parameter in python function using numba

1 view
Skip to first unread message

Esaie Kuitche

unread,
Jul 19, 2016, 4:03:25 PM7/19/16
to Numba Public Discussion - Public

How can I do to pass a class as parameter and use numba also , this is an example that didn't work???

import numba
from numba import *

class MyClass:
    """A simple example class"""
    i = 12345

    def f(self):
        return 'hello world'
c= MyClass()



def main(c):
     print c.i

test = jit(numba.typeof(c))(main)

if __name__ == '__main__':
     cls = MyClass()
     test(cls)


Siu Kwan Lam

unread,
Jul 21, 2016, 6:54:31 PM7/21/16
to Numba Public Discussion - Public
Numba cannot compile code that uses arbitrary python classes.  You will need to use the jitclass feature described in http://numba.pydata.org/numba-doc/0.27.0/user/jitclass.html#basic-usage .  


--
You received this message because you are subscribed to the Google Groups "Numba Public Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to numba-users...@continuum.io.
To post to this group, send email to numba...@continuum.io.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/numba-users/6c4a2de4-4465-47b2-85f7-6e915f52de49%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.
--
Siu Kwan Lam
Software Engineer
Continuum Analytics
Reply all
Reply to author
Forward
0 new messages