[OT] fortran lib which provide python like data type
Hi, I am not sure here is the right place to ask this question, but I want to give it a shot:) are there fortran libs providing python like data type, such as set, dict, list? Thanks, Yours liuzhenhai -- https://mail.python.org/mailman/listinfo/python-list
基于cython的即时编译器cyjit,欢迎大家提建议
我正在写一个使用cython code作为后端的即时编译器名为cyjit,将python code 转换为cython code再编译为c extension导入.设计上主要参考numba.jit的思路,使用decorate来指定要编译的function,例如: from cyjit import jit @jit('int(int,int)') def add(a,b): return a+b add(1,2)#compiled @jit('int(int,int)', locals=''' int c ''') def add1(a,b): c=add(a,b)# fast invoked return c add1(1,2) 目前还不支持类型推导,需要手动使用c的语法对局部变量进行定义。 编译过程是在jit函数中完成的,后续计划将编译过程移到函数运行时完成,实现重载。 目前支持编译cache,第一次运行需要编译,时间稍慢,再次运行直接导入编译好的extension,速度就很快了。 欢迎大家fork,pull,提建议。 https://github.com/liuzhenhai/cyjit -- https://mail.python.org/mailman/listinfo/python-list
Re: 基于cython的即时编译器cyjit,欢迎大家提建议
sorry,wrong version post 发自我的 iPhone 在 Jun 12, 2014,0:16,mm0fmf n...@mailinator.com 写道: On 11/06/2014 10:37, 1989lzhh wrote: 我正在写一个使用cython code作为后端的即时编译器名为cyjit,将python code 转换为cython code再编译为c extension导入.设计上主要参考numba.jit的思路, 使用decorate来指定要编译的function,例如: from cyjit import jit @jit('int(int,int)') def add(a,b): return a+b add(1,2)#compiled @jit('int(int,int)', locals=''' int c ''') def add1(a,b): c=add(a,b)# fast invoked return c add1(1,2) 目前还不支持类型推导,需要手动使用c的语法对局部变量进行定义。 编译过程是在jit函数中完成的,后续计划将编译过程移到函数运行时完成,实现 重载。 目前支持编译cache,第一次运行需要编译,时间稍慢,再次运行直接导入编译好 的extension,速度就很快了。 欢迎大家fork,pull,提建议。 https://github.com/liuzhenhai/cyjit You might say that but I couldn't possibly comment. -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: 基于cython的即时编译器cyjit,欢迎大家提建议
在 Jun 12, 2014,1:16,Skip Montanaro s...@pobox.com 写道: You might say that but I couldn't possibly comment. You could run the message through Google Translate. It's not publication quality translation, but serves the needs in this instance. (Gmail offers to translate the OP's message for me.) Here's what GT produced (successfully translates the Chinese, but destroys the code structure in the process - what's wrong with those people at Google? wink): Thanks skip, I post the email into wrong mail list, I will rewrite it into English. :) I'm writing a cython code using the compiler as a backend instant named cyjit, the python code Convert cython code is then compiled c extension import. Designed primarily reference numba. jit ideas, Use decorate to specify compile function, for example: from cyjit import jit @ Jit ('int (int, int)') def add (a, b): return a + b add (1,2) # compiled @ Jit ('int (int, int)', locals ='' ' int c '' ') def add1 (a, b): c = add (a, b) # fast invoked return c add1 (1,2) Currently does not support the type of derivation, C syntax to use local variables defined manually. Jit compilation process is done in the function of Follow-up plans to move to complete the compilation process runtime functions to achieve overloading. Currently supports compilation cache, you need to compile the first run, slower time, Run again compiled directly into the extension, the speed very quickly. Welcome to fork, pull, and suggestions. https://github.com/liuzhenhai/ cyjit The translation's quality is quite good, I will edit it and post here again. Thanks The concept looks like of interesting. Skip -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
A JIT compiler 'cyjit' using cython code as a backend
I'm writing a JIT compiler named cyjit using cython code as a backend. It designed primarily reference numba.jit. the jitted python function will be converted to cython code then compiled to c extension. Use decorate to specify compiled function. for example: from cyjit import jit @ jit ('int (int, int)') def add (a, b): return a + b add (1,2) # compiled @ jit ('int (int, int)', locals ='' ' int c '' ') def add1 (a, b): c = add (a, b) # fast invoked return c add1 (1,2) Currently cyjit does not support type defer, the local variables can be defined manually using C syntax. Jit compilation process is done inside jit decorate. I am planing to move compilation process into function's runtime to achieve overload like numba.jit. Currently cyjit supports compilation cache, the compilation will happen at the first run, it will take longer time. When you run it again, it will load the compiled extension directly. Welcome to fork, pull, and suggestions. https://github.com/liuzhenhai/cyjit -- https://mail.python.org/mailman/listinfo/python-list
strange behaivor of nested function
here is code def make(): def jit(sig): def wrap(function): sig=sig[0] # unbound local error, if change to sig='' would be just fine return function return wrap return jit jit=make() @jit('') def f(): pass It is strange that the interpreter complain about unbound local error. please give me some suggestion, thanks! Ps: I am using python 2.7 Liu Zhenhai 发自我的 iPhone -- https://mail.python.org/mailman/listinfo/python-list
How to use imported function to get current globals
Here is the code m1.py def f(): print globals() m2.py from m1 import f f()# how to get current module's globals? -- https://mail.python.org/mailman/listinfo/python-list
Re: How to use imported function to get current globals
发自我的 iPhone 在 Jun 8, 2014,4:52,Chris Angelico ros...@gmail.com 写道: On Sun, Jun 8, 2014 at 3:40 AM, 1989lzhh 1989l...@gmail.com wrote: Here is the code m1.py def f(): print globals() m2.py from m1 import f f()# how to get current module's globals? As Ian said, you almost certainly do not want to do this. But if you have a solid use-case that involves finding the caller's globals, you can do it (in CPython - no idea about other Pythons) with the backtrace. Could you give an example ? I do want to get the caller's globals, so I can expose something into current module implicitly. Thanks! Liu zhenhai Normally, passing dictionaries around is going to be MUCH more useful. (And probably not actually globals(), you almost never want to use that.) ChrisA -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: How to use imported function to get current globals
thanks all you guys. I have find the solution which is quite simple by using sys._frame(1).f_locals in function to get the caller's scope The following is my user case: I am writing a tool to translate python code to cython code then compiled using decorate. jit, build=make(mymodule) #jit function collect python code and signature then translate to cython code @jit('int(int)', locals=''' int b; ''') def f(a): b=1 return a+1 build()# compile cython code and load compiled module then expose compiled function to current namespace. So this is my purpose to get caller's scope f()# now f is a compiled function 发自我的 iPhone 在 Jun 8, 2014,10:24,Dave Angel da...@davea.name 写道: 1989lzhh 1989l...@gmail.com Wrote in message: Here is the code m1.py def f(): print globals() m2.py from m1 import f f()# how to get current module's globals? As others have said, it's probably a bad idea. I can think of 3 reasons to try: teacher said so, writing a debugger, transliterating code from a crude language into python. Could you elaborate on what you really want? Which of those two modules is your main script? Which code in which module is trying to get which module's globals? And is the connection static or dynamic? And do you want a snapshot of them, or to be able to modify and track changes? -- DaveA -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list