On 18/05/2018 15:47, Chris Angelico wrote:
On Sat, May 19, 2018 at 12:37 AM, bartc <b...@freeuk.com> wrote:
Have a look at some of the implementations here (to test some Mandelbrot
benchmark):
https://benchmarksgame-team.pages.debian.net/benchmarksgame/performance/mandelbrot.html
The three Python examples all use 'import sys' and 'import multiprocessing',
none of which I can find any trace of as any sort of files let alone .py.
One of them also uses 'import array', which I can't find either.
I guess you didn't look very hard.
import multiprocessing
multiprocessing.__file__
'/usr/local/lib/python3.8/multiprocessing/__init__.py'
But you have to load it first to find out. (And if you follow nested
imports, you will eventually get to those that don't have a .py file.)
import array
array.__file__
'/usr/local/lib/python3.8/lib-dynload/array.cpython-38m-x86_64-linux-gnu.so'
I get "module 'array' has no attribute '__file__'".
However, if I load sys, multiprocessing and array, then print
sys.modules, I get a very long list of modules, at which point anyone
thinking of emulating the behaviour of those modules would promptly give up.
------------------------
(BTW here's a port of that benchmark based on the Lua code:
https://pastebin.com/raw/ivDaKudX
The actual language is not relevant, as this is clear enough that it
could probably be re-implemented on anything. The 'files' module is only
needed for openfile, closefile, and 'outbyte', which should be standard
in any language. ('writebytes' might not be, so that was changed to a loop.)
The point of all this: writing clean simple code has a big advantage,
and I think my version is one of the cleanest (even though it writes to
a file, not the console).
Although it should be pointed out that these programs are pulling out
all the stops in order to get the best performance; clarity wasn't a
priority. But they should all use the same algorithm (to be within the
rules), and it is that we're trying to extract.)
--
bartc
--
https://mail.python.org/mailman/listinfo/python-list