Python’s string representation is optimized to use less memory, depending on what the string contents are.įirst, every string has a fixed overhead. Why is that? A brief digression: Python’s string memory representation Once we load it into memory and decode it into a text (Unicode) Python string, it takes far more than 24MB. That’s why actual profiling is so helpful in reducing memory usage and speeding up your software: the real bottlenecks might not be obvious.Įven if loading the file is the bottleneck, that still raises some questions. However, in this case they don’t show up at all, probably because peak memory is dominated by loading the file and decoding it from bytes to Unicode. In addition, there should be some usage from creating the Python objects. So that’s one problem: just loading the file will take a lot of memory. Def load ( fp, *, cls = None, object_hook = None, parse_float = None, parse_int = None, parse_constant = None, object_pairs_hook = None, ** kw ): """Deserialize ``fp`` (a ``.read()``-supporting file-like object containing
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |