On Sep 25, 2008, at 7:53 PM, cesarnda wrote: > I am using the "set([])" function, and is a set of vectors, I want to > convert it to a set because I want to use the methods for sets > > On Sep 25, 9:09 pm, Jason Grout <[EMAIL PROTECTED]> wrote: >> cesarnda wrote: >>> is there a function that can convert a list to a set without >>> verifying >>> if there are equal elements?, i.e., I am creating a large set >>> (cardinality = 9^5) of vectors, so the constructions takes too long >>> ( around 25 seconds), but I know all the vectors are distinct, so is >>> there a way to add an element into a set without verifying if the >>> element is already in the set? or >> >> What sort of sets are you using? The python sets use a >> dictionary, so >> it is generally very fast to see if an element already exists in >> the set. >> >> If you know everything is distinct, why don't you just keep it as >> a list? >> >> Jason
I doubt there is a way to make a set without uniqueness verification, but if it's taking so long, perhaps make sure the hash and equality functions aren't slow. I believe sets are based on hashtables, so even for that range things should be fast enough. sage: L = srange(9^5) sage: time S = set(L) CPU times: user 0.01 s, sys: 0.01 s, total: 0.01 s How long does [hash(a) for a in your_list] take? - Robert --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---