**Describe the bug**
Thank you for creating taichi language. I want to know how… to use pyc files in computation.
**To Reproduce**
Consider 3 files below.
```py
# hello.py
from core import *
print(add(1,2))
print(six_times_big(10))
```
```python
# core.py
import taichi as ti
def add(a, b):
return a+b
@ti.func
def triple(a):
return a * 3
@ti.kernel
def six_times_big(a:float) -> float:
temp = triple(a)
return temp * 2
```
```python
# compile.py
import py_compile
for i in ["hello.py", "core.py"]:
py_compile.compile(i)
```
Use `python3 compile.py` and rename files in `__pycache__` to `hello.pyc` and `core.pyc` then run `python3 hello.pyc`, this will work if using module numpy but not module taichi.
**Log/Screenshots**
Please post the **full log** of the program (instead of just a few lines around the error message, unless the log is > 1000 lines). This will help us diagnose what's happening. For example:
```
$ python my_sample_code.py
[Taichi] mode=release
[Taichi] preparing sandbox at /var/folders/25/2mxhd1b50sbc1_njhz_93jn80000gn/T/taichi-fcvyqhf8
[Taichi] version 0.7.15, llvm 10.0.0, commit cff542ce, osx, python 3.8.8
3
[Taichi] materializing...
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/sourceinspect/__init__.py", line 150, in our_findsource
return inspect._si_old_findsource(object)
File "/usr/local/Cellar/python@3.8/3.8.8_1/Frameworks/Python.framework/Versions/3.8/lib/python3.8/inspect.py", line 798, in findsource
raise OSError('could not get source code')
OSError: could not get source code
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/sourceinspect/__init__.py", line 96, in blender_findsourcetext
import bpy
ModuleNotFoundError: No module named 'bpy'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/sourceinspect/__init__.py", line 153, in our_findsource
return blender_findsource(object)
File "/usr/local/lib/python3.8/site-packages/sourceinspect/__init__.py", line 110, in blender_findsource
lines, text_name = blender_findsourcetext(object)
File "/usr/local/lib/python3.8/site-packages/sourceinspect/__init__.py", line 98, in blender_findsourcetext
raise IOError('Not in Blender environment!')
OSError: Not in Blender environment!
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/sourceinspect/__init__.py", line 38, in remote_findsource
assert module[0] == '<' and module[-1] == '>' or module in ['__console__', '__main__']
AssertionError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/sourceinspect/__init__.py", line 156, in our_findsource
return remote_findsource(object)
File "/usr/local/lib/python3.8/site-packages/sourceinspect/__init__.py", line 40, in remote_findsource
raise IOError(f'Object `{repr(object)}` does not come from console')
OSError: Object `<function six_times_big at 0x1329a3310>` does not come from console
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/sourceinspect/__init__.py", line 159, in our_findsource
return dill_findsource(object)
File "/usr/local/lib/python3.8/site-packages/sourceinspect/__init__.py", line 145, in dill_findsource
return dill.source.findsource(object)
File "/usr/local/lib/python3.8/site-packages/dill/source.py", line 154, in findsource
raise IOError('could not extract source code')
OSError: could not extract source code
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "hello.py", line 5, in <module>
File "/usr/local/lib/python3.8/site-packages/taichi/lang/kernel.py", line 571, in wrapped
return primal(*args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/taichi/lang/kernel.py", line 499, in __call__
self.materialize(key=key, args=args, arg_features=arg_features)
File "/usr/local/lib/python3.8/site-packages/taichi/lang/kernel.py", line 311, in materialize
src = remove_indent(oinspect.getsource(self.func))
File "/usr/local/lib/python3.8/site-packages/sourceinspect/__init__.py", line 185, in getsource
return inspect.getsource(object)
File "/usr/local/Cellar/python@3.8/3.8.8_1/Frameworks/Python.framework/Versions/3.8/lib/python3.8/inspect.py", line 997, in getsource
lines, lnum = getsourcelines(object)
File "/usr/local/Cellar/python@3.8/3.8.8_1/Frameworks/Python.framework/Versions/3.8/lib/python3.8/inspect.py", line 979, in getsourcelines
lines, lnum = findsource(object)
File "/usr/local/lib/python3.8/site-packages/sourceinspect/__init__.py", line 161, in our_findsource
raise IOError(f'Could not get source code for object: {repr(object)}')
OSError: Could not get source code for object: <function six_times_big at 0x1329a3310>
```
**Additional comments**
If possible, please also consider attaching the output of command `ti diagnose`. This produces the detailed environment information and hopefully helps us diagnose faster.
```
[Taichi] mode=release
[Taichi] preparing sandbox at /var/folders/25/2mxhd1b50sbc1_njhz_93jn80000gn/T/taichi-0hhdclqp
[Taichi] version 0.7.15, llvm 10.0.0, commit cff542ce, osx, python 3.8.8
*******************************************
** Taichi Programming Language **
*******************************************
Docs: https://taichi.rtfd.io/zh_CN/latest
GitHub: https://github.com/taichi-dev/taichi
Forum: https://forum.taichi.graphics
Taichi system diagnose:
python: 3.8.8 (default, Feb 27 2021, 02:19:17)
[Clang 12.0.0 (clang-1200.0.32.29)]
system: darwin
executable: /usr/local/opt/python@3.8/bin/python3.8
platform: macOS-11.2.3-x86_64-i386-64bit
architecture: 64bit
uname: uname_result(system='Darwin', node='appledeMacBook-Pro.local', release='20.3.0', version='Darwin Kernel Version 20.3.0: Thu Jan 21 00:07:06 PST 2021; root:xnu-7195.81.3~1/RELEASE_X86_64', machine='x86_64', processor='i386')
locale: zh_CN.UTF-8
PATH: /Users/apple/Documents/1_gery/2_tool_by_gery:/usr/local/texlive/2020/bin/x86_64-darwin:/Users/apple/.nimble/bin:/Users/apple/.local/bin:/usr/local/opt/coreutils/libexec/gnubin:/Users/apple/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
PYTHONPATH: ['/usr/local/bin', '/Users/apple/Documents/1_gery/2_tool_by_gery', '/usr/local/Cellar/python@3.8/3.8.8_1/Frameworks/Python.framework/Versions/3.8/lib/python38.zip', '/usr/local/Cellar/python@3.8/3.8.8_1/Frameworks/Python.framework/Versions/3.8/lib/python3.8', '/usr/local/Cellar/python@3.8/3.8.8_1/Frameworks/Python.framework/Versions/3.8/lib/python3.8/lib-dynload', '/usr/local/lib/python3.8/site-packages', '/Users/apple/Documents/1_gery/1_coding_zone/3_python_价值投资_极其仰赖/09stackprinter-master', '/usr/local/lib/python3.8/site-packages/taichi/core/../lib']
`lsb_release` not available: [Errno 2] No such file or directory: 'lsb_release'
TAICHI_REPO_DIR=
import: <module 'taichi' from '/usr/local/lib/python3.8/site-packages/taichi/__init__.py'>
cc: False
cpu: True
metal: True
opengl: False
cuda: False
`glewinfo` not available: [Errno 2] No such file or directory: 'glewinfo'
`nvidia-smi` not available: [Errno 2] No such file or directory: 'nvidia-smi'
[Taichi] mode=release
[Taichi] preparing sandbox at /var/folders/25/2mxhd1b50sbc1_njhz_93jn80000gn/T/taichi-6v_tgwo0
[Taichi] version 0.7.15, llvm 10.0.0, commit cff542ce, osx, python 3.8.8
[Taichi] mode=release
[Taichi] preparing sandbox at /var/folders/25/2mxhd1b50sbc1_njhz_93jn80000gn/T/taichi-3hhj9d5z
[Taichi] version 0.7.15, llvm 10.0.0, commit cff542ce, osx, python 3.8.8
[Taichi] Starting on arch=x64
[W 03/17/21 18:38:50.703] [__init__.py:adaptive_arch_select@589] Arch=[<Arch.opengl: 6>] is not supported, falling back to CPU
[Taichi] mode=release
[Taichi] preparing sandbox at /var/folders/25/2mxhd1b50sbc1_njhz_93jn80000gn/T/taichi-7p8g2sww
[Taichi] version 0.7.15, llvm 10.0.0, commit cff542ce, osx, python 3.8.8
[Taichi] Starting on arch=x64
[W 03/17/21 18:38:52.431] [__init__.py:adaptive_arch_select@589] Arch=[<Arch.cuda: 4>] is not supported, falling back to CPU
[Taichi] mode=release
[Taichi] preparing sandbox at /var/folders/25/2mxhd1b50sbc1_njhz_93jn80000gn/T/taichi-6u47384s
[Taichi] version 0.7.15, llvm 10.0.0, commit cff542ce, osx, python 3.8.8
[Taichi] Starting on arch=x64
[Taichi] mode=release
[Taichi] preparing sandbox at /var/folders/25/2mxhd1b50sbc1_njhz_93jn80000gn/T/taichi-f7hachrp
[Taichi] version 0.7.15, llvm 10.0.0, commit cff542ce, osx, python 3.8.8
*******************************************
** Taichi Programming Language **
*******************************************
Docs: https://taichi.rtfd.io/zh_CN/latest
GitHub: https://github.com/taichi-dev/taichi
Forum: https://forum.taichi.graphics
Running example minimal ...
[Taichi] Starting on arch=x64
[Taichi] materializing...
>>> Running time: 0.28s
42
Consider attaching this log when maintainers ask about system information.
>>> Running time: 19.70s
```