Welcome to DU! The truly grassroots left-of-center political community where regular people, not algorithms, drive the discussions and set the standards. Join the community: Create a free account Support DU (and get rid of ads!): Become a Star Member Latest Breaking News General Discussion The DU Lounge All Forums Issue Forums Culture Forums Alliance Forums Region Forums Support Forums Help & Search

BootinUp

(47,144 posts)
Wed Mar 1, 2023, 04:59 PM Mar 2023

Python 3.14 Will be Faster than C++ (Not really)

Article is about the new version of Python programming language. The author uses a variation of the Monte Carlo algorithm to estimate the value of Pi. https://en.m.wikipedia.org/wiki/Pi

Excerpt

Python is one of the most used scripting languages in data science (DS) and machine learning (ML). According to ‘PopularitY of Programming Languages’ Python is the most searched language on Google. Next to being a great glue language to connect various DS/ML solutions together, it has many libraries to virtually do anything with data.
In about a month we get a fresh new yearly release of Python: version 3.11. I am quite excited about this new version as the main feature for this version is a significant increase in speed.
On LinkedIn I have already seen a couple of post of people testing the new version and their results were stunning. But the best method to get a feeling on how fast Python 3.11 truly is, is to run the tests yourself.

https://towardsdatascience.com/python-3-14-will-be-faster-than-c-a97edd01d65d?gi=660d39c1c7ae

11 replies = new reply since forum marked as read
Highlight: NoneDon't highlight anything 5 newestHighlight 5 most recent replies
 

Hugh_Lebowski

(33,643 posts)
1. Our shop has some big Python projects coming up and I've been asked to familiarize myself
Wed Mar 1, 2023, 05:19 PM
Mar 2023

I'm actually a DBA/SQL coder but OOL's are not unfamiliar, I know a bit of Java and PHP ... more like I can read them and figure out what they're doing, but coding from scratch myself is a bit of a challenge.

Actually taking a Python tutorial for work right now, Codecademy

BootinUp

(47,144 posts)
2. I setup and run a little sql server
Wed Mar 1, 2023, 06:14 PM
Mar 2023

For our lab data. The Monte Carlo algorithm always fascinated me. It was used long before computers.

Edit correction. I was thinking of another algorithm but the Monte Carlo is also fascinating https://en.m.wikipedia.org/wiki/Monte_Carlo_method

 

Hugh_Lebowski

(33,643 posts)
5. MS Sql Server is my main jam, and our biggest client uses it
Wed Mar 1, 2023, 06:43 PM
Mar 2023

But we have others on mySQL and some legacy Oracle stuff (which I hate).

Another task today is converting some SQL Server scripts to mySQL format as we need the same functionality on both platforms.

Thing that's pissing me off right now is that

Select top 1 * from table; (mssql)
and
Select * from table limit 1; (mysql)

Don't always work the same way. I mean if the query is THAT simple they do, but start adding a lot of other stuff (most of my queries are beasts), and they don't. Frustrating me as we speak

BootinUp

(47,144 posts)
6. Currently I use the MS product but I have
Wed Mar 1, 2023, 06:51 PM
Mar 2023

Also worked some with MySQL. I totally understand well a little anyway. Soon it will be Miller time.

BootinUp

(47,144 posts)
9. So is it due to a difference in how the results are sorted?
Wed Mar 1, 2023, 11:18 PM
Mar 2023

Not too long ago I worked out why a query didn't sort like I expected it to. A dash character in a NCHAR data type was what made it sort strangely. NCHAR type is unicode. I changed the data type to CHAR and that worked for me. Been too long since I worked with MySQL 9 years, to remember specifics about it.

Edit: It could have been NVARCHAR to VARCHAR too, I don't do this stuff everyday.

lapfog_1

(29,199 posts)
3. I assume this was some sort of joke
Wed Mar 1, 2023, 06:25 PM
Mar 2023

I looked at the article, the author does a number of tests with different versions of python to show that the interpreter (python is interpreted, not compiled) is getting faster and faster with each version. Then the author PROJECTS that future versions of python will continue to exhibit the same increase of speed compared to the previous version... a huge assumption, and projects an intercept point to his other language C++.

Of course this is fallacy.

That's similar to charting the temperature of a city in the northern hemisphere from winter to summer... and then predicting that (after some more time) that city will be as hot as the sun.

I guess I'm "that one guy" the author sort of dismisses.

I pick the correct language to write software for the application and requirement. C is useful for things at are in or near the kernel of the Operating System and which are run frequently and need to be executed taking the least amount of resource. python is good for data analytics, building software quickly, and you don't care so much about execution speed or resource usage, scripting language for those Q & D things you want to prototype.. and which have a limited scope, where you really don't case about speed or resource. Same with Java and javascript, html, etc.

And... some scientists are just married to using matlab and Fortran for doing their complex numerical modeling.

when you go build a house, you don't just take 1 hammer in the toolbox.

BootinUp

(47,144 posts)
4. I guess you were bored and didnt
Wed Mar 1, 2023, 06:27 PM
Mar 2023

Finish the article. It was not a serious statement as you guessed and as I indicated in the thread title. Both the author and I are certainly going to agree with you about choosing the right tool.

mike_c

(36,281 posts)
7. lol, I wrote a text preprocessor and HTML generator in R once
Wed Mar 1, 2023, 07:35 PM
Mar 2023

I used it for a good ten years, once per semester to format class and lab schedules for my syllabi, .

BootinUp

(47,144 posts)
8. I just used R to format and export data from MS SQL
Wed Mar 1, 2023, 10:11 PM
Mar 2023

it was my first time using it. Pretty powerful.

SorellaLaBefana

(144 posts)
11. You are SO right: It is the entire development cycle which is important
Wed Apr 5, 2023, 06:39 AM
Apr 2023

After all, if it is simply execution speed which is paramount, then the only answer is the chip's native machine language bypassing any OS.

Of course, writing ML is functionally impossible for humans however assembler will do the job (years ago I put in my time here coding video drivers). Even so, it's hard to get it right in a finite amount of time even if you do use hooks to an OS for leverage. And, when you are all done, the result will only run on a particular architecture

It is also discouraging when you write a routine in assembler and in C and then find that the C is faster. Disassembling the complied C, you see where you went faceplantingly wrong

My actual point, is the same as yours: Language Wars totally miss the point. Use the Right Tool for the job. This is something which is often forgotten

Jim__

(14,075 posts)
10. Python-based compiler achieves orders-of-magnitude speedups
Tue Mar 14, 2023, 09:07 PM
Mar 2023

Codon - write Python code and then its gets compiled by a Codon compiler.

From TechXplore:



Codon is a Python-based compiler that aims to democratize high-performance computing. Credit: Alex Shipps/MIT CSAIL via Midjourney
__________________________________________________________________________________________________

...

The high-level language has earned its popularity, too, with legions of users flocking daily to the language for its ease of use due in part to its simple and easy-to-learn syntax. This led researchers from MIT's Computer Science and Artificial Intelligence Laboratory (CSAIL) and elsewhere to make a tool to help run Python code more efficiently and effectively while allowing for customization and adaptation to different needs and contexts. The compiler, which is a software tool that translates source code into machine code that can be executed by a computer's processor, lets developers create new domain-specific languages (DSLs) within Python—which is typically orders of magnitude slower than languages like C or C++—while still getting the performance benefits of those other languages.

DSLs are specialized languages tailored to specific tasks that can be much easier to work with than general-purpose programming languages. However, creating a new DSL from scratch can be a bit of a headache.

"We realized that people don't necessarily want to learn a new language, or a new tool, especially those who are nontechnical. So we thought, let's take Python syntax, semantics, and libraries and incorporate them into a new system built from the ground up," says Ariya Shajii, Ph.D. , lead author on a new paper about the team's new system, Codon. "The user simply writes Python like they're used to, without having to worry about data types or performance, which we handle automatically—and the result is that their code runs 10 to 100 times faster than regular Python. Codon is already being used commercially in fields like quantitative finance, bioinformatics, and deep learning."

The team put Codon through some rigorous testing, and it punched above its weight. Specifically, they took roughly 10 commonly used genomics applications written in Python and compiled them using Codon, and achieved five to 10 times speedups over the original hand-optimized implementations. Besides genomics, they explored applications in quantitative finance, which also handles big datasets and uses Python heavily. The Codon platform also has a parallel backend that lets users write Python code that can be explicitly compiled for GPUs or multiple cores, tasks that have traditionally required low-level programming expertise.

more ...


Latest Discussions»Culture Forums»Science»Python 3.14 Will be Faste...