Issue1480
Created on 2009-09-29.11:03:40 by ssteiner, last changed 2014-06-19.07:46:47 by zyasoft.
msg5202 (view) |
Author: simon steiner (ssteiner) |
Date: 2009-09-29.11:03:40 |
|
myfile is a 1MB text file. This takes few seconds on python or jep.
<script language="jython" setbeans="false">
<![CDATA[
t = ''
f = open(r'myfile')
for l in f:
t = t + l
f.close()
]]>
</script>
|
msg5203 (view) |
Author: simon steiner (ssteiner) |
Date: 2009-09-29.11:11:47 |
|
Seems i need to use StringIO
|
msg5204 (view) |
Author: Jim Baker (zyasoft) |
Date: 2009-09-29.16:07:06 |
|
Use StringIO (as ssteiner suggests), cStringIO, or accumulate in a list,
then join together.
CPython now optimizes this one case of accumulating strings so that it's
not quadratic in performance. Naively, it is an optimization that we
should be able to do too once we have a smarter compiler (the SSA work),
although it may not be a high priority.
|
msg8741 (view) |
Author: Jim Baker (zyasoft) |
Date: 2014-06-19.07:46:47 |
|
No smarter compiler forthcoming for this type of work (the SSA work didn't pan out). CPython can do certain types of local optimizations around loops that are not possible under the GC model used by Java and consequently Jython.
|
|
Date |
User |
Action |
Args |
2014-06-19 07:46:47 | zyasoft | set | status: open -> closed resolution: remind -> wont fix messages:
+ msg8741 |
2013-02-19 19:07:17 | fwierzbicki | set | nosy:
+ fwierzbicki resolution: remind versions:
+ Jython 2.7, - 2.5.0 |
2009-09-29 16:07:32 | zyasoft | set | priority: low |
2009-09-29 16:07:06 | zyasoft | set | keywords:
+ RFE nosy:
+ zyasoft, thobes messages:
+ msg5204 title: Loop through file is slow -> String accumulation is quadratic in Jython in a case that CPython is linear |
2009-09-29 11:11:47 | ssteiner | set | messages:
+ msg5203 |
2009-09-29 11:03:40 | ssteiner | create | |
|