Operator Precedence: One Thing Python Got Right
BartC
bc at freeuk.com
Mon Jun 27 10:14:13 EDT 2016
On 27/06/2016 15:04, Grant Edwards wrote:
> On 2016-06-27, Steven D'Aprano <steve at pearwood.info> wrote:
>
>> Do you write much Python code that you expect to also be valid C code?
>
> Depends on what you mean by "much", but yes, it's certainly something
> I do. I often develop and test algorithms in Python and then
> cut/paste much of the Python code into C programs. The more validated
> code I can use verbatim, the less likely I'll bork something up by
> having to translate it from Python to C.
>
I bet your code isn't very 'Pythonic' then!
I have frequently had to convert foreign algorithms (into my own
languages), and when there is a choice, such as on the Computer Language
Shootout site, then I might typically choose Pascal or Lua as being the
simplest and clearest to understand.
Languages such as Python tend to be too fond of using their unique
features (which I also think can be a bit of a cheat when trying to
compare benchmarks, but that's another matter). Unique features, which
can include just using a built-in library call to do the work, don't
translate so easily!
--
Bartc
More information about the Python-list
mailing list