Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Many alligators will be slain, but the swamp will remain.


devel / comp.lang.python / Re: Call julia from Python: which package?

SubjectAuthor
o Re: Call julia from Python: which package?Chris Angelico

1
Re: Call julia from Python: which package?

<mailman.16.1639780715.1567.python-list@python.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=20850&group=comp.lang.python#20850

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: rosuav@gmail.com (Chris Angelico)
Newsgroups: comp.lang.python
Subject: Re: Call julia from Python: which package?
Date: Sat, 18 Dec 2021 09:38:21 +1100
Lines: 35
Message-ID: <mailman.16.1639780715.1567.python-list@python.org>
References: <DB6PR01MB3895EBB76034AF96B9BD5D8883789@DB6PR01MB3895.eurprd01.prod.exchangelabs.com>
<CAHVvXxScU6ONFGq66Uy37Bk0k+HOnKiKF51y_9ZUbT0S+-N6yA@mail.gmail.com>
<CAPTjJmormmRVfRj-HWYcT1yLvGifA=MV7KjO_c2HG5NauufA0g@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de byjkAl7U6XLCe43Kq8v47A+DiEQEnfJr7xZMFstHapHA==
Return-Path: <rosuav@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=Gza6c5Rx;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.001
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'library.': 0.05;
"python's": 0.05; 'usage': 0.05; '"python': 0.07; 'underlying':
0.07; '18,': 0.09; 'likes': 0.09; 'objects,': 0.09; 'overhead':
0.09; 'received:209.85.128.46': 0.09; 'received:mail-
wm1-f46.google.com': 0.09; 'timing': 0.09; 'subject:Python': 0.12;
'(it': 0.16; '(there': 0.16; 'approach,': 0.16; 'chrisa': 0.16;
'cpython': 0.16; 'date,': 0.16; 'from:addr:rosuav': 0.16;
'from:name:chris angelico': 0.16; 'heavily': 0.16; 'integer':
0.16; 'purely': 0.16; 'slow': 0.16; 'subject:package': 0.16;
'subject:which': 0.16; 'wrapper': 0.16; 'wrote:': 0.16; 'python':
0.16; 'says': 0.17; 'values': 0.17; 'code.': 0.17; 'uses': 0.19;
'implement': 0.19; 'to:addr:python-list': 0.20; 'languages': 0.22;
'sat,': 0.22; 'code': 0.23; 'idea': 0.24; '(and': 0.25; 'library':
0.26; 'subject:Call': 0.26; "wasn't": 0.26; 'done': 0.28; 'asked':
0.29; 'approach': 0.31; 'dec': 0.31; 'think': 0.32;
'to:name:python': 0.32; 'message-id:@mail.gmail.com': 0.32; 'but':
0.32; 'same': 0.34; 'work.': 0.34; 'header:In-Reply-To:1': 0.34;
'received:google.com': 0.34; 'from:addr:gmail.com': 0.35;
'currently': 0.37; 'subject:from': 0.37; "it's": 0.37;
'received:209.85': 0.37; 'means': 0.38; 'received:209': 0.39;
'still': 0.40; 'advantage': 0.40; 'case.': 0.40; 'should': 0.40;
'inline': 0.61; 'skip:o 10': 0.61; "there's": 0.61; 'here': 0.62;
'true': 0.63; 'simply': 0.63; 'between': 0.63; 'clear': 0.64;
'url:%3': 0.67; 'operations': 0.68; 'creator': 0.69; 'hybrid':
0.69; '2016': 0.70; '2021': 0.71; 'note:': 0.71; 'url:%20': 0.71;
'performance': 0.71; '(that': 0.84; 'optimise': 0.84; 'oscar':
0.84; 'represented': 0.84; 'said:': 0.84; 'colleagues': 0.97
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=mime-version:references:in-reply-to:from:date:message-id:subject:to;
bh=u/3j1K8paX9AlpVu20Jbg/cUW77fhUpGgcSDPJVNidA=;
b=Gza6c5Rxw0Mq3qZH5MnWLRGwKIppEfRubJmCKgR+9hl0lgxgRJrjIiyLEAe1+oLNSY
VpH5SSYrk7+flVgRqlcVhrCX4ZaxeSNwZMOLhFxstYQhuM4cGV5vV3ytuJBD8AyJySS8
j1miwraWFtwZNCk5GzfPfDB+NSLFQmGBOk99oSBugaE5E+j4CQFHybgCs9I0NpFYf9nH
DSSSdP5HxgrSQoctNt6NK4Uzk/TLBI9ygk1gsOPE91xS6pGy4YhAlt2AbY75zX50XnGn
f1GTTkEXl6L4zsm90RW8gVnjuaI3vE3wcJUmQ53VLMS+QJvW/Bjy8Skus0E7EDDBGXMW
pTaQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=x-gm-message-state:mime-version:references:in-reply-to:from:date
:message-id:subject:to;
bh=u/3j1K8paX9AlpVu20Jbg/cUW77fhUpGgcSDPJVNidA=;
b=ssmNI9qeImx7dns4xVmK99zIYqRvX+qINnemTo3PcrvHFeUWiDTESGve0XVcA/8El2
TOif0iCudoCBXl7H9FAWch5AvAy7HTRWk8JUHAuMpbrQzIUyRC/tKYEO5RQW6+Od1Lj5
YKqvfIRqeNMeJyrQuKFx70kA1gtgJCVNVFLmWHx23/QtGQmBHWFfWhS1y0/7mDmLBlxG
AH1FQZbjLacvcrJzQxJb7QwMOZjupgHZtZpJrxE3vOZGDlxrEYI13r1DnDMDVKOhEIZL
9qxEqHJCMr5vCV/XggqRG5GQmO6p0tJMw+U6Ew/KGOEjT7PoHf7AZS6jB4Lx4Z1Vxque
ivIA==
X-Gm-Message-State: AOAM533n1T3uZkmql50DQwcrIB8qVaaCX3T/gNgMvgNduynUj0uif1DE
Fst3XMxOiQaFxkS5OcyKvDevVzBrLmXwGNUZrqAcpLdES2c=
X-Google-Smtp-Source: ABdhPJxxu3OBaY0W88tUmzL3vxi/xaBc72/Qt5uPGiAbX+thxr7vBC7LELEN1fTOhYzZjqPQL1GJu47oxA0ynB/WH/c=
X-Received: by 2002:a7b:cd0e:: with SMTP id f14mr3722888wmj.3.1639780713040;
Fri, 17 Dec 2021 14:38:33 -0800 (PST)
In-Reply-To: <CAHVvXxScU6ONFGq66Uy37Bk0k+HOnKiKF51y_9ZUbT0S+-N6yA@mail.gmail.com>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <CAPTjJmormmRVfRj-HWYcT1yLvGifA=MV7KjO_c2HG5NauufA0g@mail.gmail.com>
X-Mailman-Original-References: <DB6PR01MB3895EBB76034AF96B9BD5D8883789@DB6PR01MB3895.eurprd01.prod.exchangelabs.com>
<CAHVvXxScU6ONFGq66Uy37Bk0k+HOnKiKF51y_9ZUbT0S+-N6yA@mail.gmail.com>
 by: Chris Angelico - Fri, 17 Dec 2021 22:38 UTC

On Sat, Dec 18, 2021 at 9:24 AM Oscar Benjamin
<oscar.j.benjamin@gmail.com> wrote:
> When I timed the result in Julia and in Python I found that the Julia
> code was slower than the Python code. Of course I don't know how to
> optimise Julia code so I asked one of my colleagues who does (and who
> likes to proselytise about Julia). He pointed me to here where the
> creator of Julia says "BigInts are currently pretty slow in Julia":
> https://stackoverflow.com/questions/37193586/bigints-seem-slow-in-julia#:~:text=BigInts%20are%20currently%20pretty%20slow,that%20basic%20operations%20are%20fast.
> I should make clear here that I used the gmpy2 library in Python for
> the basic integer operations which is a wrapper around the same gmp
> library that is used by Julia. That means that the basic integer
> operations were being done by the same gmp library (a C library) in
> each case. The timing differences between Python and Julia are purely
> about overhead around usage of the same underlying C library.

Point of note: "Python actually uses a hybrid approach where small
integer values are represented inline and only when values get too
large are they represented as BigInts" might be sorta-kinda true for
Python 2, but it's not true for Python 3. In all versions of CPython
to date, all integers are objects, they're not "represented inline"
(there *are* some languages that do this intrinsically, and I think
that PyPy can sometimes unbox integers, but CPython never will); and
the performance advantage of Py2's machine-sized integers clearly
wasn't worth recreating in Py3. (It would be possible to implement it
in Py3 as an optimization, while still having the same 'int' type for
both, but nobody's done it.)

So if Python's integers are faster than Julia's, it's not because
there's any sort of hybrid approach, it's simply because CPython is
more heavily optimized for that sort of work.

(That said: I have no idea whether a StackOverflow answer from 2016 is
still applicable.)

ChrisA


devel / comp.lang.python / Re: Call julia from Python: which package?

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor