Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Superior ability breeds superior ambition. -- Spock, "Space Seed", stardate 3141.9


devel / comp.lang.python / Re: C is it always faster than nump?

SubjectAuthor
o Re: C is it always faster than nump?Avi Gross

1
Re: C is it always faster than nump?

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: avigr...@verizon.net (Avi Gross)
Newsgroups: comp.lang.python
Subject: Re: C is it always faster than nump?
Date: Fri, 25 Feb 2022 19:43:04 +0000 (UTC)
Lines: 52
Message-ID: <mailman.26.1645818189.2329.python-list@python.org>
References: <CABcwF5=bLWRKgv7M2CRom5LwBCLojxnEq9SYeEDrFiEn5Gfxog@mail.gmail.com>
<2c0d93a8-5ea5-9b63-c3cd-183446d21446@Damon-Family.org>
<375047121.1338435.1645818184031@mail.yahoo.com>
Reply-To: Avi Gross <avigross@verizon.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de VWYj73B4eDBEbx4sX3A25Ac1fOj+2K6zZpuEPuvjcNoQ==
Return-Path: <avigross@verizon.net>
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=verizon.net header.i=@verizon.net header.b=FsPKkDY8;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.131
X-Spam-Level: *
X-Spam-Evidence: '*H*': 0.74; '*S*': 0.00; '2022': 0.05; 'modules':
0.07; 'thing.': 0.07; 'attempts': 0.09; 'cases.': 0.09; 'damon':
0.09; 'interfaces': 0.09; 'much,': 0.09; 'numerical': 0.09;
'numpy': 0.09; 'pandas': 0.09; 'url:mailman': 0.15; 'alphabet':
0.16; 'attributes': 0.16; 'confused': 0.16; 'constraints.': 0.16;
'impressive': 0.16; 'mostly,': 0.16; 'nothing.': 0.16; 'numpy,':
0.16; 'paradigms': 0.16; 'pythonic': 0.16; 'slow': 0.16;
'somewhat': 0.16; 'structures': 0.16; 'subject:always': 0.16;
'wrote:': 0.16; 'python': 0.16; 'feb': 0.17; 'uses': 0.19;
'hardware': 0.19; 'implement': 0.19; 'libraries': 0.19; 'to:addr
:python-list': 0.20; 'language': 0.21; 'written': 0.22;
'languages': 0.22; 'fri,': 0.22; 'version': 0.23; 'code': 0.23;
'run': 0.23; 'list,': 0.24; 'to:name:python-list@python.org':
0.24; 'skip:- 10': 0.25; 'url-ip:188.166.95.178/32': 0.25; 'url-
ip:188.166.95/24': 0.25; 'python,': 0.25; 'saying': 0.25;
'url:listinfo': 0.25; 'url-ip:188.166/16': 0.25; 'library': 0.26;
'object': 0.26; 'suspect': 0.26; 'local': 0.27; 'ideas': 0.28;
'am,': 0.31; 'url-ip:188/8': 0.31; 'program': 0.31; 'think': 0.32;
'carefully': 0.32; 'lists,': 0.32; 'programmers': 0.32;
'structure': 0.32; 'but': 0.32; 'there': 0.33; 'hold': 0.33;
'same': 0.34; 'package': 0.34; 'header:In-Reply-To:1': 0.34;
'running': 0.34; 'complex': 0.35; 'meaning': 0.35; 'runs': 0.35;
'built': 0.36; 'people': 0.36; 'those': 0.36; 'hard': 0.37; 'way':
0.38; 'could': 0.38; 'two': 0.39; 'quite': 0.39; 'adding': 0.39;
'least': 0.39; 'list': 0.39; 'on.': 0.39; 'advantage': 0.40;
'program.': 0.40; 'support.': 0.40; 'including': 0.60; 'likely':
0.61; 'skip:o 10': 0.61; 'from:': 0.62; 'to:': 0.62; '25,': 0.62;
'merge': 0.62; 'key': 0.64; 'extend': 0.64; 'overall': 0.64;
're:': 0.64; 'richard': 0.64; 'thus': 0.64; 'your': 0.64; 'came':
0.65; 'similar': 0.65; 'well': 0.65; 'named': 0.65; 'less': 0.65;
'let': 0.66; 'areas': 0.67; 'matter': 0.68; 'change.': 0.69;
'interpreted': 0.69; 'times': 0.69; 'took': 0.69; 'within': 0.69;
'pieces': 0.70; 'compared': 0.71; 'speed': 0.71; 'care': 0.71;
'combination': 0.76; 'features.': 0.76; 'languages,': 0.76; 'yes':
0.76; 'sent:': 0.78; 'major': 0.78; 'header:Reply-To:1': 0.79;
'choices': 0.84; 'constraints': 0.84; 'converted': 0.84;
'falling': 0.84; 'mere': 0.84; 'received:74.6.129.81': 0.84;
'received:sonic317-26.consmr.mail.bf2.yahoo.com': 0.84;
'richard.': 0.84; 'speaking,': 0.84; 'supposedly': 0.84; 'holds':
0.91; 'largely': 0.91; 'particular,': 0.91; 'subject:than': 0.91;
'tend': 0.91; 'locked': 0.93; 'operates': 0.93
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=verizon.net; s=a2048;
t=1645818185; bh=WcZ3QhnnXniRB1MfW4YyJd4T9iwnMikYTMZ49COdAjk=;
h=Date:From:Reply-To:To:In-Reply-To:References:Subject:From:Subject:Reply-To;
b=FsPKkDY8tqIs5eDOJ5j1T6E8nAJImGyJkG16iJdSlmxpo0zzbZx7NWtu1UZ1U4O/+kBaUU1C/xXaKHPCdRmfhZc5f5buxYx/zqcxozVRirTybB99ArMCx4v1CW44rNjjEExnaAwwmKopvjx9ky79WZeM1eH2hEfh+IbO/LDi0bcvNM86ZTAFz1KDRfbmlTZkhge9lpkeKnqsYk2Gql4/V5NVX1mXApWHQofVl8yuc0eCHhGB7Gz+ueHAf0i+k1X+Xxo7CLwa5nNTTTKDNHvAotthh/fDeo0POsvhrAahNHqtgPZk2iiwvzCJV4Tc/QdGs55h7bepPHXq/BXF5pnbsQ==
X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048;
t=1645818185; bh=jPogx30D+tPZvU1cevkiE8ksi1zrQhiOXfREfpI4lzM=;
h=X-Sonic-MF:Date:From:To:Subject:From:Subject;
b=tukchd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B6iv7EdemEO965pTkSa4x
4GQuO1.7q1JJqb9Zh3kvN6UJlSOCy7b1yEEvcv8JY6SdTcKFk7TjRK_rEm82595frYC2ic3bjF6n
99uTuywv5PIgYLLrZDrs2rvNn6K75Mzm2ZSfr6vgUnw6XAoNRtEScsRIzNRS_uh1F4FQqdz6YE07
15fc0y5yTgr2jgtpIEhmTkiZRQ0.q3kB_Vvy.E_4ajTYoENMMdy1vQsjQJAgkG9hKS2nKf8sCWYU
fgPPuSzgVsdhw9abP2mEeU06KbJF3AVV9yfKV_TkiuV3gOAv_EIQfCOVu3KLeRiwxwhJiN_RJ0Sw
cGZqQK.TRm0tHwog3I4FYuVUxK94DSRX62MtYkNW7nJ_IVx0NuoVSULqzLs8hx8aNzlkjpNqYNWM
vvc63wY3P22sTdHyWQwgNnQoCGuVYG0QKKx5vSiD0CP8CvP9XQtASfn55AzP8YPQVncv3
X-Sonic-MF: <avigross@verizon.net>
In-Reply-To: <2c0d93a8-5ea5-9b63-c3cd-183446d21446@Damon-Family.org>
X-Mailer: WebService/1.1.19797 aolwebmail
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: <375047121.1338435.1645818184031@mail.yahoo.com>
X-Mailman-Original-References: <CABcwF5=bLWRKgv7M2CRom5LwBCLojxnEq9SYeEDrFiEn5Gfxog@mail.gmail.com>
<2c0d93a8-5ea5-9b63-c3cd-183446d21446@Damon-Family.org>
 by: Avi Gross - Fri, 25 Feb 2022 19:43 UTC

I agree with Richard.

Some people may be confused and think c is the speed of light and relativistically speaking, nothing can be faster. (OK, just joking. The uses of the same letter of the alphabet are not at all related. One is named for the language that came after the one named B, while the other may be short for celeritas meaning speed.)

There is no such thing as C. C does nothing. It is a combination of a language specification and some pieces of software called compilers that implement it well or less well.

There is such a thing as a PROGRAM. A program completely written in C is a thing. It can run fast or slow based on a combination of how it was written and on what data it operates on, which hardware and OS and so on. AND some of it may likely be running code from libraries written in other languages like FORTRAN that get linked into it in some way at compile time or runtime, and hooks into the local OS and so on.

So your program written supposedly in pure C, may run faster or slower. If you program a "sort" algorithm in C, it may matter if it is an implementation of a merge sort or at bubble sort or ...

As noted, numpy is largely written in C. It may well be optimized in some places but there are constraints that may well make it hard to optimize compared to some other implementation without those constraints. In particular, it interfaces with standard Python data structures at times such as when initializing from a Python List, or List of Lists, or needing to hold on to various attributes so it can be converted back, or things I am not even aware of.

So, I suspect it may well be possible to make a pure C library similar to numpy in many ways but that can only be used within a C program that only uses native C data structures. It also is possible to write such a program that is horribly slow. And it is possible to write a less complex version of numpy that does not support some current numpy functionality and overall runs much faster on what it does support.

I do wonder at the reason numpy and pandas and lots of other modules have to exist. Other languages like R made design choices that built in ideas of vectorization from the start. Python has lots of object-oriented extensibility that can allow you to create interpreted code that may easily extend it in areas to have some similar features. You can create an array-like data structure that holds only one object type and is extended so adding two together (or multiplying) ends up doing it componentwise. But attempts to do some such things often run into problems as they tend to be slow. So numpy was not written in python, mostly, albeit it could have been even more impressive if it took advantage of more pythonic abilities, at a cost.

But now that numpy is in C, pretty much, it is somewhat locked in when and if other things in Python change.

The reality is that many paradigms carried too far end up falling short.

-----Original Message-----
From: Richard Damon <Richard@Damon-Family.org>
To: python-list@python.org
Sent: Fri, Feb 25, 2022 1:48 pm
Subject: Re: C is it always faster than nump?

On 2/25/22 4:12 AM, BELAHCENE Abdelkader wrote:
> Hi,
> a lot of people think that C (or C++) is faster than python, yes I agree,
> but I think that's not the case with numpy, I believe numpy is faster than
> C, at least in some cases.
>
My understanding is that numpy is written in C, so for it to be faster
than C, you are saying that C is faster that C.

The key point is that numpy was written by skilled programmers who
carefully optimized their code to be as fast as possible for the major
cases. Thus it is quite possible for the numpy code to be faster in C
than code written by a person without that level of care and effort.

There are similar package available for many languages, including C/C++
to let mere mortals get efficient numerical processing.

--
Richard Damon

--
https://mail.python.org/mailman/listinfo/python-list

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor