Quote from: Blizzard on October 16, 2011, 07:12:07 am
- 1. __try_map: Array#index returns nil in Ruby if the element is not present in the array. I am not sure if Python does the same thing with list.index. If I remember right, list.index should return -1, i.e. generally an integer less than 0 if the element is not present in the list instance.
actually I did a test and it actually errors out is the item is not in the list so I put that line in an if statment
if obj in data: index = data.index(obj) else: index = None
Quote from: Blizzard on October 16, 2011, 07:12:07 am
- 2. __load_int32: In Ruby using unpack creates an array from a string. I'm not sure anymore if the same applies to Python. You should look into it.
your right it returns a tuple even if there is only one item. I needed to get the first item out of the tuple.
Quote from: Blizzard on October 16, 2011, 07:12:07 am
- 3. I'm not exactly sure if the operator "is" is an equivalent for "==". I know that I always avoided the "is" operator so you might wanna take a look at that as well. At least I think that for the sake of consistency you should just use "==" and "!=" everywhere.
"is" compares by identity, "==" compares by equality. It is actually a python convention to use "is" when you test for True, False or None because they are all references to the same object. is also works with strings because all strings with the same content are considered the same object (strings are immutable)
Quote from: Blizzard on October 16, 2011, 07:12:07 am
- 4. _dump_float, _load_float: Double check all pack/unpack formatting one more time. I noticed that you used <I and <f (instead of a capitalized <F).
this is correct there is no "F" format. only "f" which is a float the difference between "I" and "i" is that "I" is unsigned
Quote from: Blizzard on October 16, 2011, 07:12:07 am
- 5. _dump_string, _dump_array, _dump_hash: You used obj.size to check the string/array/hash size instead of len(obj).
you must not have the latest version because I fixed this a week or two ago. the file under editor/ARCed/src/Core is the latest version
Quote from: Blizzard on October 16, 2011, 07:12:07 am
- 6. _dump_object: I think that object.__module__ can return a module like "X.Y" and after appending the class with your code it would look like "X.Y::Z". I suggest you split the module name with "." and join it with "::" before concatenating the class name. Also make sure that __module__ returns a string and not a "Module" object or something like that.
crap your right, fixed that
Quote from: Blizzard on October 16, 2011, 07:12:07 am
- 7. Use "xrange" instead of "range". It's better.
I actually forgot about xrange I went ahead and changed that in the entire code base except where range would actually be needed
Quote from: Blizzard on October 16, 2011, 07:12:07 am
- 8. _load_object: I think you can use "classe()" instead of "classe.__new__(classe)". If any case, make sure it does the same thing that Ruby does, because "class.new" responds to "classe()" so "class.allocate" should logically respond to "classe.__new__(classe)". Class#allocate only creates the object in the memory, it doesn't call the initialize method so I hope that Python's __new__ method does the same.
python's __new__ is the same as ruby's allocate. but only for new style classes. thus if you want to write a class that can be dumped you have to make it inherent from "object"
I fixed it all but I haven't tested yet