Search Results
|
Post |
Author |
Forum |
Replies |
Views |
Posted
[asc]
|
|
|
Thread: Performance options for sys.stdout.writelines
Post: RE: Performance options for sys.stdout.writelines
Thanks all, tried a few things and will keep it as it is. Does anyone have a suggestion for enhancing performance using sys.stdout.writelines? Have not tried import multiprocessing, but I do think ... |
|
dgrunwal |
General Coding Help |
11 |
2,995 |
Aug-23-2022, 01:34 PM |
|
|
Thread: Performance options for sys.stdout.writelines
Post: RE: Performance options for sys.stdout.writelines
All was able to get the script 20% improvement, seems the sys.stdout.writelines takes the longest. Not sure if it can be enhanced for speed in case larger files come.
Dave
import difflib
import c... |
|
dgrunwal |
General Coding Help |
11 |
2,995 |
Aug-22-2022, 05:57 PM |
|
|
Thread: Performance options for sys.stdout.writelines
Post: RE: Performance options for sys.stdout.writelines
Sorry guys, the files are 20MB (not KB) anyway, there may be even larger files so I wanted to see if there was a simple way to expedite processing the sys.stdout.writelines portion of the original cod... |
|
dgrunwal |
General Coding Help |
11 |
2,995 |
Aug-22-2022, 04:52 PM |
|
|
Thread: Performance options for sys.stdout.writelines
Post: Performance options for sys.stdout.writelines
Pythonistas,
I am trying to improve performance of a simple script reading and comparing two 20KB .dat files. The diff assignment takes 42 seconds and the sys.stdout.writelines 82 seconds. Is there... |
|
dgrunwal |
General Coding Help |
11 |
2,995 |
Aug-19-2022, 08:28 PM |
|
|
Thread: Sort Differences in 2.7 and 3.10 Explained
Post: Sort Differences in 2.7 and 3.10 Explained
Python coders,
Is there a particular reason/change that causes this sort result between versions? How common is this kind of change in Python? Do most people just incrementally test their code in e... |
|
dgrunwal |
General Coding Help |
2 |
1,330 |
Apr-26-2022, 10:45 PM |
|
|
Thread: Generate a list
Post: RE: Generate a list
sasitha96,
The code provided works, of course you can simply capture to a file or code the file capture in Python. Or you could use DOS
C:\Windows\System32>dir *.exe >> E:\\mafiles.txt
... |
|
dgrunwal |
General Coding Help |
5 |
2,295 |
Sep-20-2021, 05:57 PM |
|
|
Thread: Move a key:value in a dictionary
Post: RE: Move a key:value in a dictionary
Thank you all. Worked like a charm.
In appreciation,
David |
|
dgrunwal |
General Coding Help |
4 |
2,202 |
Feb-24-2021, 02:43 PM |
|
|
Thread: Move a key:value in a dictionary
Post: Move a key:value in a dictionary
I created the following dictionary and added another key:value.
>>> super_hero_names = {
... 'Superman' : 'Clark Kent',
... 'Spiderman' : 'Peter Parker'
... }
>>>
>>&g... |
|
dgrunwal |
General Coding Help |
4 |
2,202 |
Feb-23-2021, 09:17 PM |
|
|
Thread: Behavior of Abstract Base Class
Post: RE: Behavior of Abstract Base Class
Thank you. I read the PEP https://www.python.org/dev/peps/pep-3119/ and it answered my question. I was not seeing the super() clear enough.
I don't have a particular use case for using abstract b... |
|
dgrunwal |
General Coding Help |
4 |
2,135 |
Oct-15-2020, 05:41 PM |
|
|
Thread: Behavior of Abstract Base Class
Post: Behavior of Abstract Base Class
All,
Is this behavior correct for ABC class? I expected only the method in class S to be printed. Is this the correct behavior?
import abc
from abc import ABC, abstractmethod
class R(ABC):
de... |
|
dgrunwal |
General Coding Help |
4 |
2,135 |
Oct-15-2020, 03:12 PM |
|
|
Thread: How to append to a set in Python
Post: RE: How to append to a set in Python
Thanks, I see.
Interested why the print output differs in lines 8,9.
lst = [3, 3, 22, 22, 1, 4, 5, 6, 10, 20, 40, 40, 40, 50]
dup_free = []
dup_free_set = {3, 3, 22, 22, 1, 4, 5, 6, 10, 20, 40, 4... |
|
dgrunwal |
General Coding Help |
7 |
3,914 |
Oct-01-2020, 03:16 PM |
|
|
Thread: How to append to a set in Python
Post: How to append to a set in Python
I am trying to append to a set and getting the following error:
AttributeError: 'dict' object has no attribute 'append'
lst = [3, 3, 22, 22, 1, 4, 5, 6, 10, 20, 40, 40, 40, 50]
dup_free = []
dup_fre... |
|
dgrunwal |
General Coding Help |
7 |
3,914 |
Oct-01-2020, 02:18 PM |
|
|
Thread: Cannot find Python installation folder when I install Anaconda
Post: RE: Cannot find Python installation folder when I ...
In the Spyder/Anaconda console
>>> import sys
>>> print(sys.version)
3.7.3 (default, Apr 24 2019, 15:29:51) [MSC v.1915 64 bit (AMD64)]
>>>
Also check:
Tools -> Pr... |
|
dgrunwal |
General Coding Help |
1 |
2,179 |
Jul-14-2020, 03:14 PM |
|
|
Thread: Overcoming ZeroDivisionError: division by zero Error
Post: RE: Overcoming ZeroDivisionError: division by zero...
Thank you guys for looking, code working now. Much appreciation,
Dave |
|
dgrunwal |
General Coding Help |
8 |
4,873 |
Jun-12-2020, 01:52 PM |
|
|
Thread: Overcoming ZeroDivisionError: division by zero Error
Post: RE: Overcoming ZeroDivisionError: division by zero...
Hmm, still receive ZeroDivisionError: division by zero, trying the following:
from ast import literal_eval
with open("C:\Dave\data.txt") as f :
for line in f :
name, values = line.split(... |
|
dgrunwal |
General Coding Help |
8 |
4,873 |
Jun-11-2020, 09:02 PM |
|
|
Thread: Overcoming ZeroDivisionError: division by zero Error
Post: Overcoming ZeroDivisionError: division by zero Err...
In the data set I have 5 such lists (all zero values).
Is there a way I can eliminate this error in such cases? I could simply remove the lists, but don't want to alter the true result.
from ast im... |
|
dgrunwal |
General Coding Help |
8 |
4,873 |
Jun-11-2020, 01:58 PM |
|
|
Thread: Formatting a Decimal to a Percentage
Post: Formatting a Decimal to a Percentage
I am new to the Python formatting - is there a function to round and print a percentage from a decimal?
with open("C:\file\data.txt") as f :
for line in f :
name, values = line.split(' =... |
|
dgrunwal |
General Coding Help |
2 |
4,574 |
Jun-05-2020, 03:16 PM |
|
|
Thread: Reading Multiple Lists Using SUM function
Post: RE: Reading Multiple Lists Using SUM function
Bingo buran - thanks all, BTW this is the coolest python forum. :) |
|
dgrunwal |
General Coding Help |
6 |
3,283 |
Jun-03-2020, 08:23 PM |
|
|
Thread: Reading Multiple Lists Using SUM function
Post: RE: Reading Multiple Lists Using SUM function
It's a text file with 259 identical lists like so.
p8262 = [331, 83, 112, 111, 21, 67, 8]
p8264 = [384, 84, 119, 74, 28, 51, 6]
p8401 = [330, 114, 217, 81, 11, 52, 5]
...
print(f"The sum of p826... |
|
dgrunwal |
General Coding Help |
6 |
3,283 |
Jun-03-2020, 07:16 PM |
|
|
Thread: Reading Multiple Lists Using SUM function
Post: RE: Reading Multiple Lists Using SUM function
Thanks! That works. Is there a way to read and loop through a file? Have around 300 lists. |
|
dgrunwal |
General Coding Help |
6 |
3,283 |
Jun-03-2020, 01:40 PM |