[lkml]   [2019]   [Jan]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH v2] perf scripts python: Add Python 3 support to
On 1/20/19 11:27 AM, Jonathan Corbet wrote:
> On Fri, 18 Jan 2019 16:45:04 -0800
> Tony Jones <> wrote:
>> On 1/17/19 1:45 AM, Seeteena Thoufeek wrote:
>>> +if sys.version_info[0] < 3:
>>> + import cPickle
>>> +else:
>>> + import _pickle as cPickle
>> Do you really need this?
>> pickle is already in Python2.
> Did you mean in Python3? I would agree that using it is better than
> importing the semi-hidden _pickle module.

No. I meant Python2 :)

pickle in Python2 is the python implementation
cPickle in Python2 is the C implementation.

A common pattern in Python 2.x is to have one version of a module implemented in pure Python, with an optional accelerated version implemented as a C extension; for example, pickle and cPickle. This places the burden of importing the accelerated version and falling back on the pure Python version on each user of these modules. In Python 3.0, the accelerated versions are considered implementation details of the pure Python versions. Users should always import the standard version, which attempts to import the accelerated version and falls back to the pure Python version.

I my patchset "import pickle" was sufficient for Python2 and Python3 The question I suppose is whether this script, for Python2, needs the accelerated C implementation. I decided it didn't.


 \ /
  Last update: 2019-01-21 08:25    [W:0.114 / U:7.308 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site