Click here to Skip to main content
15,891,136 members
Home / Discussions / Python
   

Python

 
AnswerRe: Updating a Dictionary in python iteratively Pin
Richard MacCutchan26-Aug-23 21:11
mveRichard MacCutchan26-Aug-23 21:11 
GeneralRe: Updating a Dictionary in python iteratively Pin
User 1604268027-Aug-23 6:27
User 1604268027-Aug-23 6:27 
GeneralRe: Updating a Dictionary in python iteratively Pin
Richard MacCutchan27-Aug-23 6:30
mveRichard MacCutchan27-Aug-23 6:30 
QuestionWhich technique to apply if function Y changes with values of X variables other than linear regression Pin
Member 106396367-Aug-23 12:42
Member 106396367-Aug-23 12:42 
AnswerRe: Which technique to apply if function Y changes with values of X variables other than linear regression Pin
Dave Kreskowiak7-Aug-23 12:57
mveDave Kreskowiak7-Aug-23 12:57 
GeneralRe: Which technique to apply if function Y changes with values of X variables other than linear regression Pin
Andre Oosthuizen7-Aug-23 23:18
mveAndre Oosthuizen7-Aug-23 23:18 
QuestionFile memory usage issues Pin
DevilDuck1236-Jul-23 20:26
DevilDuck1236-Jul-23 20:26 
AnswerRe: File memory usage issues Pin
Maverick49426-Aug-23 13:05
Maverick49426-Aug-23 13:05 
Well, there isn't quite enough information here to answer your question in specifics, but the answer is related to the fact that python retains objects in memory for some time and files which are read in whole and assigned as a string to a variable can be doubled if you then perform an operation on that variable. So, it really depends on what you are doing after you read the file in with the file data.

So, you read that 1.27GB file into memory with file = f.read()

that means you just ate 1.27GB of memory + 84M you already used for the data.

Then you want to work on each line so you do f.splitlines() or something like that and you have just created another 1.27GB of data as it split each line of the file up. It didn't get rid of the original read data, it just duplicated it to split the lines.

ideally you should try

with open(filename, 'r'):
    for line in f:
        # do something


That will use a lot less memory as you iterate through the file to do what is necessary. Assuming that is an option.
QuestionRoom arrangements Pin
ajay singh May20232-Jul-23 8:53
ajay singh May20232-Jul-23 8:53 
AnswerRe: Room arrangements Pin
Richard MacCutchan2-Jul-23 21:52
mveRichard MacCutchan2-Jul-23 21:52 
AnswerRe: Room arrangements Pin
Andre Oosthuizen3-Jul-23 0:43
mveAndre Oosthuizen3-Jul-23 0:43 
QuestionInvalid signature - Fondy payment gateway Pin
Kostiantyn Lahutin27-Jun-23 4:04
Kostiantyn Lahutin27-Jun-23 4:04 
AnswerRe: Invalid signature - Fondy payment gateway Pin
Richard MacCutchan27-Jun-23 5:23
mveRichard MacCutchan27-Jun-23 5:23 
GeneralRe: Invalid signature - Fondy payment gateway Pin
Kostiantyn Lahutin29-Jun-23 0:15
Kostiantyn Lahutin29-Jun-23 0:15 
AnswerRe: Invalid signature - Fondy payment gateway Pin
jschell28-Jun-23 6:15
jschell28-Jun-23 6:15 
GeneralRe: Invalid signature - Fondy payment gateway Pin
Kostiantyn Lahutin29-Jun-23 0:13
Kostiantyn Lahutin29-Jun-23 0:13 
AnswerRe: Invalid signature - Fondy payment gateway Pin
Maverick49426-Aug-23 13:40
Maverick49426-Aug-23 13:40 
Questionfor machin software's Pin
pilot choice18-May-23 6:31
pilot choice18-May-23 6:31 
AnswerRe: for machin software's Pin
Richard MacCutchan18-May-23 6:33
mveRichard MacCutchan18-May-23 6:33 
QuestionClosed. This question is not written in English. It is not currently accepting answers. Stack Overflow is an English-only site. If you are confident that you will be able to understand and respond to answers and comments in English, please edit your Pin
Member 1599162128-Apr-23 23:38
Member 1599162128-Apr-23 23:38 
AnswerRe: Closed. This question is not written in English. It is not currently accepting answers. Stack Overflow is an English-only site. If you are confident that you will be able to understand and respond to answers and comments in English, please edit y Pin
OriginalGriff28-Apr-23 23:48
mveOriginalGriff28-Apr-23 23:48 
AnswerRe: Closed. This question is not written in English. It is not currently accepting answers. Stack Overflow is an English-only site. If you are confident that you will be able to understand and respond to answers and comments in English, please edit y Pin
Richard MacCutchan29-Apr-23 0:20
mveRichard MacCutchan29-Apr-23 0:20 
QuestionInsensitive Match with Sensitive Substitute? Pin
Philip Derrida14-Apr-23 2:22
Philip Derrida14-Apr-23 2:22 
AnswerRe: Insensitive Match with Sensitive Substitute? Pin
OriginalGriff14-Apr-23 2:23
mveOriginalGriff14-Apr-23 2:23 
AnswerRe: Insensitive Match with Sensitive Substitute? Pin
Richard MacCutchan14-Apr-23 2:46
mveRichard MacCutchan14-Apr-23 2:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.