Code Monkey home page Code Monkey logo

funktown's People

Contributors

jimrthy avatar jruere avatar zhemao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

funktown's Issues

Hash collisions not handled properly

d = funktown.ImmutableDict()
d.assoc("1", "string")
ImmutableDict({'1': 'string'})
d.assoc("1", "string").assoc(1877051568, "int")
ImmutableDict({1877051568: 'int', '1': 'string'})
d.assoc("1", "string").assoc(1977051568, "int")
ImmutableDict({1977051568: 'int'})

Since "1" and 1977051568 have the same hash values, the one wipes out the other. The Clojure hash map is a bit more involved, but handles this situation properly.

ImmutableDict.update is different from standard

Using the same method but changing the semantics is very error prone.

It means that an immutable dict cannot just be used and see if it works because data may be being discarded unexpectedly.

It should be renamed to something else. Perhaps "updated", like there is sorted vs list.sort.

Any plans for set, sorted-set, sorted-map, & list?

Hi,

Thanks for publishing an inspiring library.

Do you have any plans for adding other immutable data structures found in clojure, such as set, sorted-set, sorted-map, and list? If so, how's progress on those plans? ๐Ÿ˜„

Comparison w/ string throws exception

d = {'a': 1, 'b': 2, 'c': 3}
i_d = ImmutableDict(d)
i_d == 'xyz'

throws a TypeError, because string indexes must be integers (and this compares them against the string keys of the dict).

This is turning up specifically when I have nested ImmutableDicts and I'm using the in operator to test for the existence of specific keys at different levels.

ImmutableDict loses data

I haven't looked through the code to see what's going on. The number of items lost changes with each rerun (new random data), so it could be a hash collision in the use of the built-in hash(). This problem might actually be in another data structures used to implement the ImmutableDict.

If you can't get around to fixing this please update the README to notify that this package is not safe to use and publish a new version so it's reflected on PyPI as well.

IPython 3.2.1 in a virtualenv on the default OSX python:

Python 2.7.6 (default, Sep  9 2014, 15:04:36)
Type "copyright", "credits" or "license" for more information.

IPython 3.2.1 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: from funktown import ImmutableDict

In [2]: from uuid import uuid4

In [3]: l = [uuid4() for _ in range(10000)]

In [4]: d = {str(uid):uid for uid in l}

In [5]: len(d), len(d.keys())
Out[5]: (10000, 10000)

In [6]: i = ImmutableDict(d)

In [7]: len(i), len(i.keys())
Out[7]: (10000, 9928)

In [8]: for key in d.keys():
   ...:     if i.get(key) is None:
   ...:         print 'key {} is missing'.format(key)
   ...:
key 59320bdc-3953-47d2-b100-e49f9da7c297 is missing
key 591f2a88-26d4-4b06-a6bf-69874fd9b67f is missing
key 39ca4436-4d56-4dae-9930-305fdda94d90 is missing
key c1049e13-9b89-4250-bce7-061fae0db4ad is missing
key 7b9146d2-1812-465a-913a-37a0d214faf7 is missing
key 58c3162f-5586-44c2-8702-426da5855e53 is missing
key bd662fc8-8389-4b1a-b7e5-99c239ed5b57 is missing
key 4419fdc8-6fc9-44ef-9538-8657a38e8d1e is missing
key 1a79937c-f776-47e2-b7e5-4676d0fb43a0 is missing
key cabb61ad-e8f0-42ef-ab4c-47b9b623f6f8 is missing
key d6588f76-6e4f-4a5a-8b0d-097da8853377 is missing
key 2ce279cd-419b-4551-a17e-84b713ee17b3 is missing
key 673f7d2f-69ff-495c-be4e-ac8a71706f79 is missing
key 1df6392e-956c-4916-9fbb-fe6385ff3d59 is missing
key d898c04e-c175-40b8-a0e8-7c842e470f19 is missing
key e56f986a-b035-47e9-b43d-b0323b67449d is missing
key cf2648cc-936a-40f7-a152-ae6c3c4444fe is missing
key b50a4c9e-ea70-4943-bf5a-079be11f3ec3 is missing
key 60daca07-92b6-48b6-962c-18902e4fe719 is missing
key 62bb0173-d6c3-46f7-b171-1319e69cf3fc is missing
key be41ed39-5dba-46d1-b962-c977a38f4604 is missing
key 2bd41c55-995b-4fa5-b3ad-efcbc0e8334d is missing
key f3a6971e-7459-4bf4-94aa-0703bd90a5a9 is missing
key 163cacc7-275d-4222-ab24-4242611b8281 is missing
key 30d20da5-382a-4c3e-8f0b-747b33d565de is missing
key c6b12a88-211e-4d6f-b7f0-041269db246f is missing
key 09e957bb-6978-4c91-9a22-b2832e3cf275 is missing
key 0fe69b17-6207-4114-a576-25a64d585af6 is missing
key ae29c952-1572-416b-acb6-3a54ab0d12a0 is missing
key 8cc6af9a-ebed-46bf-a7e9-4ccd59494425 is missing
key 412026f0-8eb8-4564-970d-3d44226b4089 is missing
key d3f0765a-5206-44ec-ba1a-4b30adadf614 is missing
key a80953b5-e278-47e3-9291-6325744cffd8 is missing
key 4ee52e41-6c00-4fd8-9c2d-6c9fe4d4044c is missing
key f1ae5143-fed2-43b2-874c-9bdbcf918f27 is missing
key c0fd078c-cc33-4fbd-a8f0-e02c9bfe6b3d is missing
key 798179b9-9fbd-4d81-be77-45cafc0e096c is missing
key 0afb7503-22dd-4369-a795-87f6bb2ab3df is missing
key 697ca29e-9737-43af-87e4-aca8d3dcd18d is missing
key b8b70a3b-6ecd-440e-861d-c08879aa8a92 is missing
key 2e940333-ba42-48fe-893a-577ee1ed2e77 is missing
key c5229b97-b3a1-41b5-98c1-0e9de441c2dd is missing
key b65f933e-a80d-4d91-8221-73ef91807689 is missing
key 9a1a9896-07bc-4f01-9c61-c8348299becb is missing
key 4578c643-8894-4da4-bc7c-d6abb7b1ac7f is missing
key 452f725f-4169-4769-b42a-334c4ab668a5 is missing
key 58fc086d-164b-44cc-b918-a47314fe4c4e is missing
key df6f4422-56ec-4e0f-93ba-adf2a258dddd is missing
key b2909398-d9e0-4d80-b755-00fcdfa03d8b is missing
key 52a9a612-6247-4276-9a17-57f5cc3c6e08 is missing
key 4e922ece-bb75-405a-abf8-b672dde9f63c is missing
key 15444d78-870b-4507-9c1e-f538db364d76 is missing
key bb21d563-3d61-4e19-942b-28d8e0fc93fd is missing
key a5a5a2de-4e86-49fc-9cd3-1a113102822d is missing
key 01860a8c-d319-4833-9734-fb053b5796bc is missing
key fb6edbfe-2617-4e76-b427-f16cc5ea2880 is missing
key 570e8873-9ddf-4ebb-86ca-14e54b4d789c is missing
key 5122a33c-05b9-4104-8e83-ab32a65ca8b2 is missing
key 9ea1bee6-36ec-4438-a06c-13cd4cd4eb1e is missing
key 9280030a-3b02-4519-93c8-b4b921b7c2e1 is missing
key c8093dba-37a7-4a6e-9762-b6a6593be7dc is missing
key 5728ce58-5cb1-42cc-a3e6-ef0543b56bd1 is missing
key dd66398e-4d83-4e5f-927f-bae758fd6231 is missing
key 0a3cb99e-8f85-4f24-822a-371a0624fb97 is missing
key 87204107-ae68-4ae4-b473-4e18fd08087b is missing
key dec3112b-20d3-44de-b8ad-78f17f2e0386 is missing
key 1d5e8de8-69a3-40b6-afaa-717f16e749ab is missing
key 02091678-4e84-4422-a90f-204081cc98a9 is missing
key 8026426e-2dcf-4200-997e-7ced8f93fa71 is missing
key dc8bbf21-f346-47ad-a9ac-2ead5df6aab2 is missing
key 14d8d359-2fc8-44f3-8be9-c6a92b66b796 is missing
key 5232612f-b2f7-48b6-a019-568d8575ff94 is missing

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.