On May 18, 2015, at 9:23 PM, Galen Charlton <[log in to unmask]> wrote:
>> I have two scripts, attached. They do EXACTLY the same thing
>> in almost EXACTLY the same manner, but the Python script is
>> almost 25 times slower than the Perl script:
>
> I'm no Python expert, but I think that the difference is much more
> likely due to which JSON processor is being used. I suspect your Perl
> environment has the JSON::XS module, which is written in C, is fast,
> and is automatically invoked (if present) by "use JSON;".
>
> In contrast, I believe that the Python "json" library is written in
> Python itself. I tried swapping in cjson and UltraJSON [1] in place
> of "json" in your Python script, and in both cases it ran rather
> faster.
>
> [1] https://github.com/esnme/ultrajson
Thank you. After using the Python module ujson instead of json, the speed of my two scripts is now all but equal. Whew! —Eric
|