mmm wrote:
>>> Hence (if I understand python convention), this can be
>>> solved by adding
>>> sqlx= copy.copy(sqlx)
>>> before the looping. And in tests adding this step saved about 5-10% in
>>> time.
>> Now this I don;t really understand at all. What's the point of trying to
>> replace sqlx with a copy of itself? Perhaps if you explained what you
>> hope this will achieve I could comment more intelligently.
>>
> 
> I am/was attempting to convert
> 
>   sqlx= 'INSERT INTO %s VALUES ( %s ) ' % (dtable,ph)
> 
> to code that did to need to be re-evaluated.  i.e. to insert the
> dtable and ph values as if they were hard coded.
> 
> copy.copy -->  A shallow copy constructs a new compound object and
> then (to the extent possible) inserts references into it to the
> objects found in the original.

Unfortunately you weren't dealing with a compound object object here, so 
all you are doing is creating a copy of the string you've just created 
and replacing the original with it. Copy.copy() is meant for creating 
(say) lists, tuples and dicts where the elements are references to the 
same objects that the elements of the original structure referred to.

regards
  Steve
-- 
Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC              http://www.holdenweb.com/

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to