pySQLite Insert speed
Steve Holden
steve at holdenweb.com
Tue Mar 4 08:05:57 EST 2008
mmm wrote:
> Steve, I think you were right the first time is saying
>
>> it should really be this:
>> sqlxb= 'INSERT INTO DTABLE2 VALUES (?, ?, ?, ?)'
>
> my copy.copy() has the equivalent effect.
>
> Running this test code produces the output below
>
> import copy
>
> print 'Test 1'
> pf= '?,?,?,?'
> sqlx1= 'INSERT INTO DTABLE2 VALUES ( %s ) ' % pf
> print sqlx1
>
> print
> print 'Test 2'
> sqlx2= copy.copy(sqlx1)
> sqlx3= sqlx1
> pf= '?,?,?, ****'
> sqlx1= 'INSERT INTO DTABLE2 VALUES ( %s ) ' % pf
> print 'sqlx1= ', sqlx1
> print 'sqlx2= ', sqlx2
> print 'sqlx3= ', sqlx2
>
> == output
> Test group 1
> INSERT INTO DTABLE2 VALUES ( ?,?,?,? )
>
> Test group 2
> sqlx1= INSERT INTO DTABLE2 VALUES ( ?,?,?, **** )
> sqlx2= INSERT INTO DTABLE2 VALUES ( ?,?,?,? )
> sqlx3= INSERT INTO DTABLE2 VALUES ( ?,?,?,? )
>
> I interpret this to mean that sqlx1 is not a simple string
Sorry, since you didn't copy and paste the actual code you ran I don't
regard those results as reliable.
What I will repeat, however, is that while there is a *slight*
difference is semantics between
s = "some string"
s1 = s
and
s = "some string"
s1 = copy.copy(s)
that difference is only to ensure that s and s1 point to different
copies of the same string in the latter case, whereas in the former case
s and s1 point to the same string.
Since strings are immutable in Python this really doesn't make any
difference. In either case changing the value of s will leave the value
of s1 unchanged, since it will still point to the string it was
originally bound to and s will point to some other string.
I suspect some superstition is at play here, or possibly you are cargo
cult programming :)
regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/
More information about the Python-list
mailing list