Support for new items in set type

Steven D'Aprano steve at REMOVE.THIS.cybersource.com.au
Sun Apr 22 02:09:12 EDT 2007


On Sat, 21 Apr 2007 20:13:44 -0700, Prateek wrote:

> I have a bit of a specialized request.
> 
> I'm reading a table of strings (specifically fixed length 36 char
> uuids generated via uuid.uuid4() in the standard library) from a file
> and creating a set out of it.
> Then my program is free to make whatever modifications to this set.
> 
> When I go back to save this set, I'd like to be able to only save the
> new items. 

This may be a silly question, but why? Why not just save the modified set,
new items and old, and not mess about with complicated transactions?

After all, you say:

> PS: Yes - I need blazing fast performance - simply pickling/unpickling
> won't do. Memory constraints are important but definitely secondary.
> Disk space constraints are not very important.

Since disk space is not important, I think that you shouldn't care that
you're duplicating the original items. (Although maybe I'm missing
something.)

Perhaps what you should be thinking about is writing a custom pickle-like
module optimized for reading/writing sets quickly.


-- 
Steven.




More information about the Python-list mailing list