On Fri, Apr 10, 2015 at 4:29 AM, Travis Griggs travisgri...@gmail.com wrote:
if k + ‘_@‘ in documents:
timeKey = k + ‘_@‘
historyKey = thingID + ‘_’ + k
I’m curious where others lean stylistically with this kind of thing. I see
*at least* 2 other alternatives:
So few? I'd
On Fri, Apr 10, 2015 at 5:19 AM, Ben Bacarisse ben.use...@bsb.me.uk wrote:
Chris Angelico ros...@gmail.com writes:
On Fri, Apr 10, 2015 at 4:46 AM, Ben Finney ben+pyt...@benfinney.id.au
wrote:
Travis Griggs travisgri...@gmail.com writes:
Here’s 3 examples:
if k + ‘_@‘ in documents:
I was doing some maintenance now on a script of mine… I noticed that I compose
strings in this little 54 line file multipole times using the + operator. I was
prototyping at the time I wrote it and it was quick and easy. I don’t really
care for the way they read. Here’s 3 examples:
if k +
I am under the impression that using format() is the canonically right way
to do it. It is certainly more readable than using ''.join() and is more
semantically specific than string addition.
On Thu, Apr 9, 2015 at 1:35 PM, Chris Angelico ros...@gmail.com wrote:
On Fri, Apr 10, 2015 at 4:29 AM,
Chris Angelico ros...@gmail.com writes:
On Fri, Apr 10, 2015 at 4:46 AM, Ben Finney ben+pyt...@benfinney.id.au
wrote:
Travis Griggs travisgri...@gmail.com writes:
Here’s 3 examples:
if k + ‘_@‘ in documents:
timeKey = k + ‘_@‘
historyKey = thingID + ‘_’ + k
In addition
On Fri, Apr 10, 2015 at 4:46 AM, Ben Finney ben+pyt...@benfinney.id.au wrote:
Travis Griggs travisgri...@gmail.com writes:
Here’s 3 examples:
if k + ‘_@‘ in documents:
timeKey = k + ‘_@‘
historyKey = thingID + ‘_’ + k
In addition to the other responses, I'll point out a
Travis Griggs travisgri...@gmail.com writes:
Here’s 3 examples:
if k + ‘_@‘ in documents:
timeKey = k + ‘_@‘
historyKey = thingID + ‘_’ + k
In addition to the other responses, I'll point out a different issue:
Your client is composing messages that munge your text. Ensure you
On Fri, Apr 10, 2015 at 4:44 AM, Andrew Farrell amfarr...@mit.edu wrote:
I am under the impression that using format() is the canonically right way
to do it. It is certainly more readable than using ''.join() and is more
semantically specific than string addition.
Depends what you're doing.
() : 0.032835
concatenate_string_join() : 0.170623
concatenate_string_and_encode(): 0.037280
- As we already know concatenating bytes is much slower then concatenating
strings.
- concatenate_bytearray() shows that doing this with bytearrays is 5 times
slower than concatenating strings. Also
R. David Murray added the comment:
Please take these observations and questions to python-list. They aren't
really appropriate for the bug tracker. We aren't going to add the
optimization shortcut for bytes unless someone does a bunch of convincing on
python-ideas, which seems unlikely (but
Sworddragon added the comment:
We aren't going to add the optimization shortcut for bytes
There is still the question: Why isn't this going to be optimized?
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19801
files: test.py
messages: 204503
nosy: Sworddragon
priority: normal
severity: normal
status: open
title: Concatenating bytes is much slower than concatenating strings
type: behavior
versions: Python 3.3
Added file: http://bugs.python.org/file32859/test.py
R. David Murray added the comment:
It is definitely not a good idea to rely on that optimization of += for string.
Obviously bytes doesn't have the same optimization. (String didn't either for
a while in Python3, and there was some controversy around adding it back
exactly because one
Changes by R. David Murray rdmur...@bitdance.com:
--
type: behavior - performance
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19801
___
___
Antoine Pitrou added the comment:
Indeed. If you want to concatenate a lot of bytes objects efficiently, there
are three solutions:
- concatenate to a bytearray
- write to a io.BytesIO object
- use b''.join to concatenate all objects at once
--
nosy: +pitrou
Changes by Benjamin Peterson benja...@python.org:
--
resolution: - wont fix
status: open - closed
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19801
___
hello!
since i am a py noob, please bear with me ; )
how is it possible to concat a string and an integer in a
print-command? i've tried
print This robot is named %s. The current speed setting is %d, and %s
has a lifetime of %d % (self.name , self.speed , self.name)
as well as
print This
EHC a écrit :
hello!
since i am a py noob, please bear with me ; )
how is it possible to concat a string and an integer in a
print-command? i've tried
print This robot is named %s. The current speed setting is %d, and %s
has a lifetime of %d % (self.name , self.speed , self.name)
Four
thank you, i just plainly overlooked it ; )
now it works
--
http://mail.python.org/mailman/listinfo/python-list
Hi Erich
If you're going to be doing a lot of string substitution, you should
look at the Templating support in the library:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/304005
and (a little bit fancier):
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/335308
Regards
Caleb
Sorry if this is a dumb question.
I have a list of strings (some 10,000+) and I need to concatenate them
together into one very long string. The obvious method would be, for
example:
alist=[ab,cd,ef,.,zzz]
blist =
for x in alist:
blist += x
But is there a cleaner and faster way of
Sorry if this is a dumb question.
I have a list of strings (some 10,000+) and I need to concatenate them
together into one very long string. The obvious method would be, for
example:
alist=[ab,cd,ef,.,zzz]
blist =
for x in alist:
blist += x
But is there a cleaner and faster way of
John Henry wrote:
Sorry if this is a dumb question.
I have a list of strings (some 10,000+) and I need to concatenate them
together into one very long string. The obvious method would be, for
example:
alist=[ab,cd,ef,.,zzz]
blist =
for x in alist:
blist += x
But is there a
John Henry wrote:
I have a list of strings (some 10,000+) and I need to concatenate them
together into one very long string. The obvious method would be, for
example:
alist=[ab,cd,ef,.,zzz]
blist =
for x in alist:
blist += x
But is there a cleaner and faster way of doing this?
24 matches
Mail list logo