简体   繁体   中英

Can all python code be compiled by cython as is?

I went through a few cython tutorials and felt comfortable beginning to mess around with my own conversion. The first thing I did was copy paste my python code and compile it to make sure it was working. However, the cython compiled code gives a different (and wrong) output, even though I didn't change a thing.

My understanding was that cython can compile python? I would link the code but it's fairly large in comparison to most code pasted. My biggest question is what types of python code isn't compiled correctly by cython when directly copied?

I found the solution. In python my line of code read:

TM[adjMut[f]][i] = 1 / len(fitter)

In cython i had to declare the 1 as 1.0:

TM[adjMut[f]][i] = 1.0 / len(fitter)

In many hundreds of lines of codes, that's the only difference. I'm not sure if it's a bug or intended, but there it is!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM