我将Python加速器(Numba,Cython,f2py)与简单的For循环和Numpy的einsum进行比较以解决特定问题(见下文).到目前为止,Numpy是这个问题最快的因素(速度提高了6倍),但是如果我应该尝试额外的优化,或者我做错了什么,我想要一些反馈.这个简单的代码基于一个更大的代码,它有许多这些einsum调用,但没有明确的for循环.我正在检查这些加速器是否可以做得更好.
在Mac OS X Yosemite上使用Python 2.7.9完成计时,安装了gcc-5.3.0(--with-fortran --without-multilib)来自Homebrew.也做了%timeit电话; 这些单一的通话时间相当准确.
In [1]: %run -i test_numba.py
test_numpy: 0.0805640220642
Matches Numpy output: True
test_dumb: 1.43043899536
Matches Numpy output: True
test_numba: 0.464295864105
Matches Numpy output: True
test_cython: 0.627640008926
Matches Numpy output: True
test_f2py: 5.01890516281
Matches Numpy output: True
test_f2py_order: 2.31424307823
Matches Numpy output: True
test_f2py_reorder: 0.507861852646
Matches Numpy output: True
Run Code Online (Sandbox Code Playgroud)
主要代码:
import numpy as np
import numba
import time
import test_f2py as tf2py
import pyximport
pyximport.install(setup_args={'include_dirs':np.get_include()})
import test_cython as tcyth
def test_dumb(f,b):
fnew = np.empty((f.shape[1],f.shape[2])) …Run Code Online (Sandbox Code Playgroud) 是否可以在Atom编辑器中自定义代码折叠行为?有一些我想要忽略的标签,它目前没有(例如Fortif中的#if def)
我想创建一个环境,它是我的root环境的精确副本,但不制作任何包的硬拷贝(稍后我将添加一些不在 Anaconda 中的包)。我想我可以通过以下之一来做到这一点:
conda create -n newroot --clone root
conda create -n newroot --copy root
conda create -n newroot anaconda
Run Code Online (Sandbox Code Playgroud)
但这些都是下载包。如何创建当前 Anaconda 发行版的精确副本环境?(我知道以后我可以添加软件包conda install -n newroot <package name>)