This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: heavy resource usage with string functions
Type: resource usage Stage:
Components: Library (Lib) Versions: Python 2.5
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: facundobatista, loewis, mgogoulos
Priority: normal Keywords:

Created on 2008-07-19 14:02 by mgogoulos, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg70034 - (view) Author: mgogoulos (mgogoulos) Date: 2008-07-19 14:02
Not sure if this is a bug, however the following string functions when
called with very big numbers as the padding arguments consume great
system resources. My estimation is that it would help to exist a limit
on what can be specified as width.

Check (center, ljust, rjust, zfill)

eg.

import string
string.center('..', 2147483647)

Tested on python versions: 2.5.1 and 2.5.2
msg70037 - (view) Author: Facundo Batista (facundobatista) * (Python committer) Date: 2008-07-19 14:51
The issue is that you're creating a string of 2GB. It's expectable that
it'll use a lot of resources.

Test this, for example: 

>>> a = "." * 2147483647
msg70039 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2008-07-19 15:31
As for the possibility of rejecting the request: Python should
absolutely not do so. If the user/applications wants to compute the
result, and the system has enough virtual memory, then Python should
provide the result.

If you want to limit how much memory Python can consume, use the
operating system's resource management functions (such as ulimit).
History
Date User Action Args
2022-04-11 14:56:36adminsetgithub: 47668
2008-07-19 15:31:51loewissetnosy: + loewis
messages: + msg70039
2008-07-19 14:51:37facundobatistasetstatus: open -> closed
resolution: not a bug
messages: + msg70037
nosy: + facundobatista
2008-07-19 14:02:50mgogouloscreate