Is Python interpreter inherently slow or is it just the way we code?
I've found Python programs to be much slower relative to other programming languages and this difference has been steadily increasing over time. To cite a very recent example, I've been working on this very simple programming problem on Kattis and to my surprise, the Python version took 0.06 seconds to run the exact same algorithm which PHP took 0.01 seconds - which means PHP was about six times faster than Python!
I'm sure this order of magnitude may not be reflective of real world situations but you can't deny that Python has become observably slower while the competition has caught up in recent years.
#different.py (Python 3.8)
while(True):
try:
vals = input().split()
if len(vals) !=2: break
a, b = int(vals0), int(vals1)
print(abs(a - b))
except EOFError:
/r/Python
https://redd.it/1c1z7mt
I've found Python programs to be much slower relative to other programming languages and this difference has been steadily increasing over time. To cite a very recent example, I've been working on this very simple programming problem on Kattis and to my surprise, the Python version took 0.06 seconds to run the exact same algorithm which PHP took 0.01 seconds - which means PHP was about six times faster than Python!
I'm sure this order of magnitude may not be reflective of real world situations but you can't deny that Python has become observably slower while the competition has caught up in recent years.
#different.py (Python 3.8)
while(True):
try:
vals = input().split()
if len(vals) !=2: break
a, b = int(vals0), int(vals1)
print(abs(a - b))
except EOFError:
/r/Python
https://redd.it/1c1z7mt
Reddit
From the Python community on Reddit
Explore this post and more from the Python community
Django Template not working as expected
Hello everyone.
I have the following objects
```
class ManyToManyObjects(models.Model):
id
ObjectA = models.ForeignKey('A')
ObjectB= models.ForeignKey('A') #Different Objects, but for sake of argument lets say they are the same.
Objectmatch = models.CharField}
ObjectScore = models.IntegerField()
Class A(models.Models):
id
data
```
(Redacted some of it for simplicity, but these are the main fields for this interaction.)
And I have the following in my Django Template:
```
{% assign prevmatch '' %}
{% assign lastA ''%}
{% assign lastB ''%}
{% for match in ManyToManyObjects %}
{% if prevcod != match.Objectmatch %}
... //just some sort of header for the table
/r/djangolearning
https://redd.it/1iu2c47
Hello everyone.
I have the following objects
```
class ManyToManyObjects(models.Model):
id
ObjectA = models.ForeignKey('A')
ObjectB= models.ForeignKey('A') #Different Objects, but for sake of argument lets say they are the same.
Objectmatch = models.CharField}
ObjectScore = models.IntegerField()
Class A(models.Models):
id
data
```
(Redacted some of it for simplicity, but these are the main fields for this interaction.)
And I have the following in my Django Template:
```
{% assign prevmatch '' %}
{% assign lastA ''%}
{% assign lastB ''%}
{% for match in ManyToManyObjects %}
{% if prevcod != match.Objectmatch %}
... //just some sort of header for the table
/r/djangolearning
https://redd.it/1iu2c47
Reddit
From the djangolearning community on Reddit
Explore this post and more from the djangolearning community