From: Dan P. <da...@ag...> - 2009-02-04 22:21:39
|
On Tuesday 03 February 2009, Oleg Broytmann wrote: > On Tue, Feb 03, 2009 at 02:37:16PM -0500, Stef Telford wrote: > > Oleg Broytmann wrote: > > > Because SQLObject needs to generate unique alias names and a global > > > counter is the simplest way to do it. Think about joining a table > > > with itself - you need two different names for the table. > > > > Sorry, perhaps I am being stupid here (always a possability) but, how > > many self joins are we expecting in a query ? I mean to say, isn't > > saying 'selfName = self.__class__.__name__ + "_%d" % int(random())' > > good enough ? > > Are you sure calling random() and int() is really so much faster > than lock/increase counter/unlock? > Are you sure you are optimizing a real stumbling block? I do not think that the issue is one of speed, but one of correctness. Locks plus an incrementing counter is safe and correct. Random numbers are not. While they may work most of the time, they may also fail under given circumstances which is unacceptable. -- Dan |