[Tutor] Concatenation vs formatting

bob gailer bgailer at gmail.com
Mon Sep 1 19:51:19 CEST 2008


Richard Lovely wrote:
> Just a couple of quick questions:
> What differences are there in efficency (i.e. time and memory) between
> string concatenation ("foo" + "bar") and printf style formatting
> ("%s%s" % ("foo","bar")).
> Is there any place where one is better than the othe
concatenation should be more efficient as formatting takes 4 more 
bytecodes than concatenation, one of which is binary_format which will 
take more execution time.

However unless your application does many of those it is not worth the 
effort to choose one over the other. I almost always favor formatting as 
it is so much easier to read, maintain and extend.

-- 
Bob Gailer
Chapel Hill NC 
919-636-4239

When we take the time to be aware of our feelings and 
needs we have more satisfying interatctions with others.

Nonviolent Communication provides tools for this awareness.

As a coach and trainer I can assist you in learning this process.

What is YOUR biggest relationship challenge?



More information about the Tutor mailing list