John J. Lee wrote:
Duncan Booth [EMAIL PROTECTED] writes:
[...]
str.join(sep, list_of_str)
[...]
Doesn't work with unicode, IIRC.
str.join won't work if sep is unicode, but generally you know what type the
separator is and str.join will quite happily join a list of strings where
Martin v. Löwis [EMAIL PROTECTED] writes:
[...]
Of course that statement is also false. Performance prediction is very
difficult, and you cannot imply much from this benchmark. In other
[...]
s/imply/infer/
John
--
http://mail.python.org/mailman/listinfo/python-list
Duncan Booth [EMAIL PROTECTED] writes:
[...]
str.join(sep, list_of_str)
[...]
Doesn't work with unicode, IIRC.
John
--
http://mail.python.org/mailman/listinfo/python-list
Andreas Beyer wrote:
Yeeh, I was expecting something like that. The only reason to use map()
at all is for improving the performance.
That is lost when using list comprehensions (as far as I know). So, this
is *no* option for larger jobs.
Don't believe anything you hear right away, especially
Andreas Beyer wrote:
If I am getting the docs etc. correctly, the string-module is depricated
and is supposed to be removed with the release of Python 3.0.
I still use the module a lot and there are situations in which I don't
know what to do without it. Maybe you can give me some help.
Out of
Martin v. Löwis [EMAIL PROTECTED] writes:
Out of curiosity: when thinking about Python 3.0, what is the timespan
in which you expect that to appear? Before 2010? After 2010? After 2020?
I'm not terribly worried about Python 3.0 incompatibilities, whenever
those are. There are already three
John J. Lee wrote:
Duncan Booth [EMAIL PROTECTED] writes:
[...]
str.join(sep, list_of_str)
[...]
Doesn't work with unicode, IIRC.
u .join([What's, the, problem?])
uWhat's the problem?
--
http://mail.python.org/mailman/listinfo/python-list
Dan Bishop wrote:
John J. Lee wrote:
Doesn't work with unicode, IIRC.
u .join([What's, the, problem?])
uWhat's the problem?
str.join(x, y) isn't quite a drop-in replacement for
string.join(y, x), since it's not polymorphic on the
joining string:
str.join(u , [a, b])
Traceback (most recent call
Andreas Beyer [EMAIL PROTECTED] writes:
OK, you won. I read in an (regretably old) guidline for improving
Python's performance that you should prefer map() compared to list
comprehensions. Apparently the performance of list comprehensions has
improved a lot, which is great. (Or the overhead
Andreas Beyer wrote:
I loved to use
string.join(list_of_str, sep)
instead of
sep.join(list_of_str)
I think the former is much more telling what is happening than the
latter. However, I will get used to it.
No need to get used to it. Just reverse the order of the arguments and use:
OK, you won. I read in an (regretably old) guidline for improving
Python's performance that you should prefer map() compared to list
comprehensions. Apparently the performance of list comprehensions has
improved a lot, which is great. (Or the overhead of calling map() got
too big, but I hope
Andreas Beyer writes:
Yeeh, I was expecting something like that. The only reason to
use map() at all is for improving the performance. That is
lost when using list comprehensions (as far as I know). So,
this is *no* option for larger jobs.
Skip Montanaro replied:
Did you test your
Hi All--
Michael Chermside wrote:
The REAL lesson here is that you shouldn't follow any optimization
rules without actually testing them. If you don't have time to test,
then just don't optimize... write whatever is most readable. If you
NEED more speed, then profiling and testing will show
Ivan Van Laningham wrote:
Tim Peters sayeth, Premature Optimization is the Root of All Evil.
And he is not kidding.
And just to forestall another long thread about who
actually said that originally, it was really Mark
Twain, quoting Churchill. Tim just added a wink.
-Peter
--
Hi:
If I am getting the docs etc. correctly, the string-module is depricated
and is supposed to be removed with the release of Python 3.0.
I still use the module a lot and there are situations in which I don't
know what to do without it. Maybe you can give me some help.
I loved to use
upper_list = map(string.upper, list_of_str)
Andreas What am I supposed to do instead?
Try
[s.upper() for s in list_of_str]
Skip
--
http://mail.python.org/mailman/listinfo/python-list
Yeeh, I was expecting something like that. The only reason to use map()
at all is for improving the performance.
That is lost when using list comprehensions (as far as I know). So, this
is *no* option for larger jobs.
Andreas
Skip Montanaro wrote:
upper_list = map(string.upper, list_of_str)
Hi All--
Andreas Beyer wrote:
I loved to use
string.join(list_of_str, sep)
instead of
sep.join(list_of_str)
I think the former is much more telling what is happening than the
latter. However, I will get used to it.
I disagree, but maybe you could think of it as a mutant list
Andreas Beyer wrote:
Yeeh, I was expecting something like that. The only reason to use
map() at all is for improving the performance.
That is lost when using list comprehensions (as far as I know). So,
this is *no* option for larger jobs.
Try it and see. You'll probably be pleasantly
Hey Andreas,
I loved to use
string.join(list_of_str, sep)
instead of
sep.join(list_of_str)
I think the former is much more telling what is happening than the
latter. However, I will get used to it.
I find that binding a name to the separator makes it more readable
(YMMV):
Andreas Yeeh, I was expecting something like that. The only reason to
Andreas use map() at all is for improving the performance. That is
Andreas lost when using list comprehensions (as far as I know). So,
Andreas this is *no* option for larger jobs.
Did you test your hypothesis?
On Thu, Mar 31, 2005 at 08:32:20PM -0800, Andreas Beyer wrote:
Hi:
If I am getting the docs etc. correctly, the string-module is depricated
and is supposed to be removed with the release of Python 3.0.
I still use the module a lot and there are situations in which I don't
know what to do
22 matches
Mail list logo