Poll

Do you like Python?

Yes, I love it.
22 (24.2%)
Yes, I like it.
24 (26.4%)
No, I don't like it
17 (18.7%)
No, I hate it.
14 (15.4%)
No opinion, indiferent
11 (12.1%)
I refuse to answer
3 (3.3%)

Total Members Voted: 90

Author Topic: Python becomes the most popular language  (Read 97012 times)

0 Members and 2 Guests are viewing this topic.

Offline mansaxel

  • Super Contributor
  • ***
  • Posts: 3554
  • Country: se
  • SA0XLR
    • My very static home page
Re: Python becomes the most popular language
« Reply #175 on: October 31, 2021, 06:52:01 am »

So the point is what is fun?

An extraordinarily impressive increase in complexity that made the whole thing look like an episode of the television series "Big Bang Theory" ;D

I feel a bit responsible but not guilty here :-DD and I'd like to simply point out that doing something "the wrong way" deliberately can be fun, and as Nominal Animal pointed out, that is until people who are not in on the joke take it seriously and deploy it in production...  :scared:
« Last Edit: October 31, 2021, 06:54:23 am by mansaxel »
 
The following users thanked this post: DiTBho

Offline mfro

  • Regular Contributor
  • *
  • Posts: 210
  • Country: de
Re: Python becomes the most popular language
« Reply #176 on: October 31, 2021, 07:04:47 am »
I am sick of such "sums"

Agreed.

Forget C..  this is too OLD crap..

Rust can at least bootstrap itself, Python can't. Anyway, without C, neither of the two would exist. Every language has its purpose.
Beethoven wrote his first symphony in C.
 

Online PicuinoTopic starter

  • Frequent Contributor
  • **
  • Posts: 730
  • Country: 00
    • Picuino web
Re: Python becomes the most popular language
« Reply #177 on: October 31, 2021, 08:39:04 am »
Quicksort algorithm over long long numbers:

Python Time = 3.5579
C Time = 0.2170

Relationship = 3.5579 / 0.2170 = 16.4 : 1

I think you may be mostly measuring startup time there. Try with a bigger array, or do it multiple times.
Array of 10000000 numbers:

Python: 46.36
C: 5.95
Relation: 7.8

 

Offline SL4P

  • Super Contributor
  • ***
  • Posts: 2318
  • Country: au
  • There's more value if you figure it out yourself!
Re: Python becomes the most popular language
« Reply #178 on: October 31, 2021, 10:18:56 am »
Let’s look back a few years…
Assembly code without much optimisation…
MSBASIC was fine on 8-bitters, running at 4MHz or less - through the late 70s and 80s for many of us, until CBASIC and PASCAL rolled along, and we could do 80% more with 20% extra coding effort,  then Java and some others stumbled into the shot.
Easy to write, but inefficient.
C already had an audience, then C++, and C# arrived.

They all matured, and diverged as ‘web applications’, and ‘the cloud’ started to show up.
(Client-Server anyone)

HTML and then Python arrived to make GUIs and single-user applications a bit easier to write, but luckily, computers had increased their hardware performance by more than 100x - sadly the code ran at effectively the same speed, you could write code that appeared the same speed to the single user, but occupied 80% of the system resources to do it!

Luckily disk and I/O evolved in parallel, along with coprocessors - to pick up the data flow bottlenecks

About now, we should consider that here we are in 2021, with 8-bit 16MHz embedded processors that are quite capable of keeping up with 3GHz, 64-bit processors on simple control projects.  Other hardware in the mid point can do the same, better.

Sure there are other benefits, but when they’re programmed with Oranges to Oranges, it becomes abundantly clear why ‘system’ programmers use the ‘harder’ languages than the easy to teach ‘application’ tools.
Don't ask a question if you aren't willing to listen to the answer.
 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 4039
  • Country: nz
Re: Python becomes the most popular language
« Reply #179 on: October 31, 2021, 10:39:30 am »
Quicksort algorithm over long long numbers:

Python Time = 3.5579
C Time = 0.2170

Relationship = 3.5579 / 0.2170 = 16.4 : 1

I think you may be mostly measuring startup time there. Try with a bigger array, or do it multiple times.
Array of 10000000 numbers:

Python: 46.36
C: 5.95
Relation: 7.8

Very strange.

I tried your code with N = 10 million

M1 Mac arm64
 0.736 C
30.895 Python

2990wx Threadripper amd64
 0.816 C
43.380 Python

SiFive FU740 1.5 GHz riscv64
  4.700 C
584.804 Python

That's ratios of 41.97, 53.16, and 124.43.

The C was compiled with -O1 on all. The C program used 80 MB of RAM, as expected, the Python used variously 800 MB, 700 MB, and 560 MB of RAM.
« Last Edit: November 02, 2021, 10:27:53 pm by brucehoult »
 

Online PicuinoTopic starter

  • Frequent Contributor
  • **
  • Posts: 730
  • Country: 00
    • Picuino web
Re: Python becomes the most popular language
« Reply #180 on: October 31, 2021, 10:43:41 am »
I have used GCC from MinGW without options

Edit: Have you changed the size of the array in the C code?
Code: [Select]
#include <stdlib.h>
#include <stdio.h>
#include <time.h>

#define ARRAYSIZE   10000000

long partition(long long *values, long left, long right, long pivotidx) {
   long long temp, pivot;
   long storeidx, idx;
   
   pivot = values[pivotidx];
   temp = values[right];
   values[right] = values[pivotidx];
   values[pivotidx] = temp;
   storeidx = left;
   for(idx = left; idx<right; idx++) {
      if (values[idx] < pivot) {
         temp = values[idx];
         values[idx] = values[storeidx];
         values[storeidx] = temp;
         storeidx++;
      }
   }
   
    temp = values[storeidx];
    values[storeidx] = values[right];
    values[right] = temp;
    return storeidx;
}

long long *_doquicksort(long long *values, long left, long right) {
   long pivotidx;

   if (right > left) {
      pivotidx = (left + right) / 2;
      pivotidx = partition(values, left, right, pivotidx);
      _doquicksort(values, left, pivotidx);
      _doquicksort(values, pivotidx + 1, right);
   }
   return values;
}

long long *quicksort(long long *nums) {
   return _doquicksort(nums, 0, ARRAYSIZE-1);
}
       
int main() {
   long i;
   clock_t timeit;
   long long *nums;
   
   
   nums = malloc(sizeof(long long)*(ARRAYSIZE+1));
   for(i=0; i<ARRAYSIZE; i++) {
      nums[i] = (long long)rand();
   }
   
   timeit = clock();
   nums = quicksort(nums);
   timeit = clock() - timeit;
   printf("time = %f\n", (float)(timeit) / CLOCKS_PER_SEC);
}

« Last Edit: October 31, 2021, 10:49:12 am by Picuino »
 

Online PicuinoTopic starter

  • Frequent Contributor
  • **
  • Posts: 730
  • Country: 00
    • Picuino web
Re: Python becomes the most popular language
« Reply #181 on: October 31, 2021, 10:53:27 am »
With -O1 option my new time is:
Python: 46.36 Seconds
C: 2.247 Seconds

New ratio: 20.6
 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 4039
  • Country: nz
Re: Python becomes the most popular language
« Reply #182 on: October 31, 2021, 11:19:15 am »
I have used GCC from MinGW without options

GCC without options is -O0 which is pessimised -- every variable is loaded from RAM in every statement, and the result stored back. Thus totally wasting the 16 or 32 perfectly good registers your CPU has.

Quote
Edit: Have you changed the size of the array in the C code?

Yes, to 10 million.
 

Online PicuinoTopic starter

  • Frequent Contributor
  • **
  • Posts: 730
  • Country: 00
    • Picuino web
Re: Python becomes the most popular language
« Reply #183 on: October 31, 2021, 11:32:17 am »
I have just installed newer version of mingw64 and I compile the program with -O1 option:

Python Time: 46.36
C time: 1.67

New ratio: 27.8 : 1
 

Online PicuinoTopic starter

  • Frequent Contributor
  • **
  • Posts: 730
  • Country: 00
    • Picuino web
Re: Python becomes the most popular language
« Reply #184 on: October 31, 2021, 11:47:45 am »
I have tested pure Python sort program just for fun:

Code: (python) [Select]
import random
import time
import numpy as np
       
def main():
   nums = np.random.randint(0, 1024*1024*1024, (1, 10000000), dtype='int64')
   timeit = time.time()
   nums.sort()
   timeit = time.time() - timeit
   print('time =', timeit)

main()

Python time = 0.776 seconds
« Last Edit: October 31, 2021, 01:57:56 pm by Picuino »
 

Online dietert1

  • Super Contributor
  • ***
  • Posts: 2073
  • Country: br
    • CADT Homepage
Re: Python becomes the most popular language
« Reply #185 on: October 31, 2021, 12:22:40 pm »
I never used Python until some weeks ago. The problem was: about 3000 wrong gif files. Those are test protocols and they indicated a wrong firmware revision. Impossible to correct all those gif files by hand (unreliable). Impossible to setup a C++ application like i usually do (time consumption).

Searching the web for help i found a Python image library that could paste into a gif image and save the change back to the file. Then i had to learn how to search a directory for all gif files in Python and prepare a small gif with the correct revision number to patch into all those files. It had to be the same color model as the protocol files to change, otherwise the image library failed to paste correctly. Also i learned how to restore the last modification date/time of the original gif files. The whole procedure was finished after 3 or 4 hours and everybody was happy.

Still i will prefer C++ for project work. To me Python appears somewhat like Arduino: Maybe useful but you can't know in advance.

Regards, Dieter
« Last Edit: October 31, 2021, 02:28:13 pm by dietert1 »
 

Online PicuinoTopic starter

  • Frequent Contributor
  • **
  • Posts: 730
  • Country: 00
    • Picuino web
Re: Python becomes the most popular language
« Reply #186 on: October 31, 2021, 01:52:11 pm »
Once you have tried Python you will use it again.
There are many tasks like what you have just done in the ordinary life of a programmer, where Python solves the problem for you.
 

Online Nominal Animal

  • Super Contributor
  • ***
  • Posts: 6264
  • Country: fi
    • My home page and email address
Re: Python becomes the most popular language
« Reply #187 on: October 31, 2021, 05:46:13 pm »
Once you have tried Python you will use it again.
Now that is just silly.

Python is only a tool among tools.  Saying that Python is something everybody should try because they will find it useful, is like saying everybody should be confident handling explosives, because you can do so much with explosives: everything from woodcutting and emergency signaling to demolition.

A case in point: If you often reach for numpy to do statistical number-crunching in Python, you should take a look at R instead.  If you do numerical linear algebra, consider Matlab or Octave.  If you do symbolic algebra (sympy), consider Maxima/wxMaxima or Sagemath instead.  And so on.

Do not let yourself be blinded and mentally bound by a comfortable tool.  That way lies silliness: you become a hammer-wielder, who sees all problems as nails.
 
The following users thanked this post: cfbsoftware

Online jfiresto

  • Frequent Contributor
  • **
  • Posts: 820
  • Country: de
Re: Python becomes the most popular language
« Reply #188 on: October 31, 2021, 06:11:05 pm »
Once you have tried Python you will use it again.
Now that is just silly.

Python is only a tool among tools.  Saying that Python is something everybody should try because they will find it useful, is like saying everybody should be confident handling explosives, because you can do so much with explosives: everything from woodcutting and emergency signaling to demolition....

Perhaps the wording was a little silly, but the sentiment is not. I might have written: once you have tried Python, you may very well find yourself using it again. It has served me well over the last decade and a half. I have found, that like C, Python wears well.

It is funny you should mention explosives. I was chatting with a neighbor, some months back, about his grandmother who had lived through the German hyperinflation and the terrible destruction of the Second World War. My neighbor said she was unflappable and prepared for any and every possible contingency. Among the things she kept on hand were some commonly available materials for making explosives. You never know when those might come in handy.
-John
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14481
  • Country: fr
Re: Python becomes the most popular language
« Reply #189 on: October 31, 2021, 06:24:41 pm »
It's just very subjective.
I have tried Python and would certainly not want to use it again. To each their own. Not saying it's not useful and the go-to tool for many; not saying that *you* or anyone else should not use it; just that it's certainly not a universal fact.

And I agree with Nominal Animal about using the "right" tool instead of trying to use Python for just everything. Almost anything for math stuff, for instance, can be done better and more comfortably with tons of dedicated tools.
 

Online Nominal Animal

  • Super Contributor
  • ***
  • Posts: 6264
  • Country: fi
    • My home page and email address
Re: Python becomes the most popular language
« Reply #190 on: October 31, 2021, 06:52:53 pm »
I might have written: once you have tried Python, you may very well find yourself using it again.
Me fail English often, but to me that is has a completely different sentiment.  The silly one was an assertion of usefulness for all, yours expresses possible utility (and uses a form that typically indicates you personally have found it useful).

I too have found Python useful for a number of use cases, but I also know cow-orkers who never touch those use cases, and computer users (developers in some sense, say writing translations and such) that do not know Python and suffer no handicap for it.

Quote
Among the things she kept on hand were some commonly available materials for making explosives. You never know when those might come in handy.
My dad had blasters permits since I was a kid.  I consider explosives and firearms just another set of tools, and was taught the basic safety practices at around preschool age, just in case.  He preferred slower, safer tools (like the expansion of water when it turns to ice to split large rocks), but explosives are surprisingly useful in non-urban environments –– if used appropriately.
 

Offline mansaxel

  • Super Contributor
  • ***
  • Posts: 3554
  • Country: se
  • SA0XLR
    • My very static home page
Re: Python becomes the most popular language
« Reply #191 on: October 31, 2021, 07:49:59 pm »
I never used Python until some weeks ago. The problem was: about 3000 wrong gif files. Those are test protocols and they indicated a wrong firmware revision. Impossible to correct all those gif files by hand (unreliable). Impossible to setup a C++ application like i usually do (time consumption).

Searching the web for help i found a Python image library that could paste into a gif image and save the change back to the file. Then i had to learn how to search a directory for all gif files in Python and prepare a small gif with the correct revision number to patch into all those files. It had to be the same color model as the protocol files to change, otherwise the image library failed to paste correctly. Also i learned how to restore the last modification date/time of the original gif files. The whole procedure was finished after 3 or 4 hours and everybody was happy.

Still i will prefer C++ for project work. To me Python appears somewhat like Arduino: Maybe useful but you can't know in advance.

Regards, Dieter

This is a typical example where Python shines, jobs that are run few times or only once, but they're worth putting effort into because the alternative is to be a Windows user and do it by clicking in a GUI 3000 times.  I do these all the time, and in shell or awk. For picture manipulation it usually ends up being a wrapper around ImageMagick or similar. If I'm posting pictures on here I usually write a one-liner calling "convert" from the ImageMagick suite, like so:

Code: [Select]
convert -strip -quality 60 DSC_0938.JPG usual_suspect.jpeg

Offline emece67

  • Frequent Contributor
  • **
  • !
  • Posts: 614
  • Country: 00
Re: Python becomes the most popular language
« Reply #192 on: October 31, 2021, 09:15:25 pm »
.
« Last Edit: August 19, 2022, 04:44:30 pm by emece67 »
 

Offline tszaboo

  • Super Contributor
  • ***
  • Posts: 7391
  • Country: nl
  • Current job: ATEX product design
Re: Python becomes the most popular language
« Reply #193 on: October 31, 2021, 10:08:19 pm »
Quicksort algorithm over long long numbers:
Again with this? This is not how you sort in python.
You sort in python with .sorted()
You dont write code, others wrote it already.
I really dont know what you are trying to prove here, other than your own ignorance on how to use the language.
 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 4039
  • Country: nz
Re: Python becomes the most popular language
« Reply #194 on: October 31, 2021, 10:24:29 pm »
I have just installed newer version of mingw64 and I compile the program with -O1 option:

Python Time: 46.36
C time: 1.67

New ratio: 27.8 : 1

That's getting more like it. But I still don't understand why your C program is so slow. I didn't change your code at all (except one million to ten million).

I don't know why you used "long long" as the data type. There's a serious danger that some machines may give 128 bits for that, not 64 bits as you want. Maybe mingw64 is doing that?  I did check on all three of my machines, and it was 64 bit, but it's a risk. If you want a specific size then you should use int64_t or uint64_t.

Maybe try putting near the start of your program:

Code: [Select]
printf("sizeof(long long) = %ld\n", sizeof(long long));

Also, I noticed you're using rand() which returns an int (32 bits on all my machines), not random() which returns a long (64 bits on all my machines).
 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 4039
  • Country: nz
Re: Python becomes the most popular language
« Reply #195 on: October 31, 2021, 10:36:06 pm »
Quicksort algorithm over long long numbers:
Again with this? This is not how you sort in python.
You sort in python with .sorted()
You dont write code, others wrote it already.
I really dont know what you are trying to prove here, other than your own ignorance on how to use the language.

Some people do things where others have already beaten down a path through the jungle.

Others *are* the people beating down the path.


I often find myself as one of the latter.

I appreciate the notational convenience of things such as list comprehensions and built-in sort functions, but I FAR PREFER to use a language where I can do things the explicit way if I want to and it performs the same. I want a language I can *write* the library in.
 
The following users thanked this post: cfbsoftware

Offline DiTBho

  • Super Contributor
  • ***
  • Posts: 3915
  • Country: gb
Re: Python becomes the most popular language
« Reply #196 on: October 31, 2021, 10:45:17 pm »
I have tried Python and would certainly not want to use it again.

Python for math seems to be mandatory. I have different feelings and opinions, but it's practically irrelevant, I have to follow the hype, otherwise there are neither libraries nor tools  :-//
The opposite of courage is not cowardice, it is conformity. Even a dead fish can go with the flow
 

Online PicuinoTopic starter

  • Frequent Contributor
  • **
  • Posts: 730
  • Country: 00
    • Picuino web
Re: Python becomes the most popular language
« Reply #197 on: November 01, 2021, 11:11:07 am »
Once you have tried Python you will use it again.
Now that is just silly.

Python is only a tool among tools.

No, Python is not only other tool. Is more popular than the other tools.
Just silly is having a simple, useful, free, ubiquitous and popular tool and not wanting to use it.

I recognize that there are many more tools and that many being specialized are more prepared for what they do. But I'm not a specialist in all those subjects and I don't need to learn R when I want to do a few statistics, or use Octave for number crunching. And of course I don't want to pay for Matlab.

I also usually use imagemagick and bash for certain tasks. Knowing Python does not make me leave out all the other tools.
I have also programmed in Awk but it was before I knew Python. Awk may be shorter to type, but only in simple tasks and I don't want to keep so many tools in my head for sporadic use.
 

Offline tszaboo

  • Super Contributor
  • ***
  • Posts: 7391
  • Country: nl
  • Current job: ATEX product design
Re: Python becomes the most popular language
« Reply #198 on: November 01, 2021, 12:22:51 pm »
Quicksort algorithm over long long numbers:
Again with this? This is not how you sort in python.
You sort in python with .sorted()
You dont write code, others wrote it already.
I really dont know what you are trying to prove here, other than your own ignorance on how to use the language.

Some people do things where others have already beaten down a path through the jungle.

Others *are* the people beating down the path.


I often find myself as one of the latter.

I appreciate the notational convenience of things such as list comprehensions and built-in sort functions, but I FAR PREFER to use a language where I can do things the explicit way if I want to and it performs the same. I want a language I can *write* the library in.
These things are not explicitly typed by python developers, because it is pointless and error prone.
If you want to use your time useful, then join the python core development team. You get to program in C and develop these menial tasks by hand. Other than posting here, saying: " Look it is slow for things that you are not meant to do".
What's next? Implicit matrix multiplication, instead of writing "a*b", and "hey look it is slower than C"?
 
The following users thanked this post: bpiphany

Online PicuinoTopic starter

  • Frequent Contributor
  • **
  • Posts: 730
  • Country: 00
    • Picuino web
Re: Python becomes the most popular language
« Reply #199 on: November 01, 2021, 12:28:32 pm »
Ok, Python is an interpreted language and therefore it is slower than C. Everybody agree with that.
But despite that, there is an ever-increasing growth of interpreted languages ​​vs. compiled languages.
Perhaps the increased speed of computers and a need for greater flexibility in programming aid in this change.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf