[python] vytváření souboru

mtip mtip na atlas.cz
Úterý Září 24 08:13:05 CEST 2019


A neukládal si to po netu?

On x86 (32-bit) or IA64 (64-bit) systems, the maximum buffer size is just under 64MB. For X64 systems, the maximum buffer size is just under 32MB.
The maximum unbuffered read and write size limits are imposed by the design of the IO manager inside the Windows executive.
When an application reads or writes files that are opened with FILE_FLAG_NO_BUFFERING,
the IO Manager locks the application's buffer into physical RAM and then maps the virtual addresses into physical addresses
to pass to the disk device by making a memory descriptor list (MDL).
The buffer size limitation comes from the maximum size MDL that the IO Manager will create.
The reason for the difference between platforms is the way the maximum buffer size is calculated from the memory page size and pointer size.
The IO Manager uses the following formula to compute the maximum size MDL:

((65535 - sizeof(MDL)) / sizeof(ULONG_PTR)) * PAGE_SIZE

This formula has the following results:

Processor Page Size Pointer Size MDL calculation
======== ======== ========= =============

x86 (32-bit) 4096 4 bytes ((65535 - 28) / 4) * 4096 = 67076096 bytes (63.97 MB)

IA64 8096 8 bytes ((65535 - 48) / 8) * 8192 = 67051520 bytes (63.95 MB)

X64 4096 8 bytes ((65535 - 48) / 8) * 4096 = 33525760 bytes (32MB - 28K)

This limitation occurs when the file is opened with FILE_FLAG_NO_BUFFERING.

Dne 23.09.2019 v 16:43 zu1234 napsal(a):
> W10 prof 32 bit
> Filesystém NTFS
> Python 2.7.15
> Opakuji: pokud soubor zapisuju po částech, tak bez problému.
> Znovu jsem to zkoušel zapsat vcelku: neprošlo cca 100MB.
> 
> Dne 23.9.2019 v 16:14 Petr Messner napsal(a):
>> Na jakém systému? Linux?
>>
>> Nezapisoval jsi soubor větší než 4 GB na FAT32?
>>
>> Nezapisoval jsi do souboru otevřeném jen pro čtení? 
>>
>> Nejsi na 32bit systému, nebo nemáš spuštěný 32bit Python?
>>
>> Jen tak na zkoušku jsem si v Pythonu 3 zkusil jedním write zapsat 20GB soubor, bez problému.
>>
>> PM
>>
>> po 23. 9. 2019 v 15:59 odesílatel zu1234 <zu1234 na seznam.cz <mailto:zu1234 na seznam.cz>> napsal:
>>
>>     IOError, 22, Invalid argument
>>
>>
>>
>>     Dne 23.9.2019 v 13:10 Petr Messner napsal(a):
>>>     A jaký byl text toho IOError? To, že to nic neříká tobě, neznamená, že to nevysvětluje tu chybu :)
>>>
>>>     file.write je high level metoda, která volá OS syscall write tolikrát, kolik je potřeba, takže teoreticky jsi omezený jen velikostí RAM.
>>>
>>>     PM
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>     po 23. 9. 2019 v 11:43 odesílatel zu1234 <zu1234 na seznam.cz <mailto:zu1234 na seznam.cz>> napsal:
>>>
>>>         Při vytváření (binárního) souboru pomocí file.write() jsem se utkal s
>>>         nic neříkající chybou io error ... .
>>>         Nakonec jsem zjistit že větší soubor je nutno zapisovat po částech a ne
>>>         naráz.
>>>         Nenašel jsem jak zjistit jak největší může ta část být.
>>>         Program funguje, ale chtěl bych vědět víc.
>>>         Orientuje se někdo lépe?
>>>         Díky ZU
>>>
>>>
>>>         _______________________________________________
>>>         Python mailing list
>>>         python na py.cz <mailto:python na py.cz>
>>>         http://www.py.cz/mailman/listinfo/python
>>>
>>>         Visit: http://www.py.cz
>>>
>>>
>>>     _______________________________________________
>>>     Python mailing list
>>>     python na py.cz <mailto:python na py.cz>
>>>     http://www.py.cz/mailman/listinfo/python
>>>
>>>     Visit: http://www.py.cz
>>
>>
> 
> 
> _______________________________________________
> Python mailing list
> python na py.cz
> http://www.py.cz/mailman/listinfo/python
> 
> Visit: http://www.py.cz
> 


Další informace o konferenci Python