Code Monkey home page Code Monkey logo

pymdict's People

Contributors

ipazc avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

pymdict's Issues

Bulk operations too slow

The bulk operations are not improving too much the speed. A research in the code shows that on each addition or modification during a bulk operation, the dictionary is marked as "modified" which requires a call to the database.

Relevant lines:

class BulkMongoDict(MongoDict):
    ...
    def __setitem__(self, key, value):
        self._on_modified_callback()
        self._operations.append(
            UpdateOne({"key": key}, {"$set": {"value": value}}, upsert=True)
        )

        if len(self._operations) > self._buffer_size:
            self.commit()

    def __delitem__(self, key):
        self._on_modified_callback()
        self._operations.append(
            DeleteOne({"key": key})
        )

        if len(self._operations) > self._buffer_size:
            self.commit()

A solution would be to delay the modified mark until a commit is performed.

OS: Debian 9
Python: 3.5.3
Pymdict: 0.0.2

On a third-party fork, my dict is not aware

My dictionary is not aware of external (outside of my process) forks of it. Example to replicate it:

Process1:

>>> a = MongoDict("a")
>>> a["foo"] = "bar"
>>> sleep(4)
>>> a["foo"] = "fa"

Process2:

>>> a = MongoDict("a")
>>> sleep(2)
>>> b = a.fork("b")  # It is supposed that b["foo"] == "bar" in the fork
>>> sleep(5)
>>> print(b["foo"])
fa

OS: Debian9
Python: 3.5.3
Pymdict: 0.0.2

Retrieving the count of elements in a query returns an invalid generator

A query call can be invoked as follows:

m = MongoDict("example")
query_elements = m('value % example')

However, when it is only required the count of the elements, it can be done as follows:

m = MongoDict("example")
query_count = m('value % example', count_only=True)

It is supposed that query_count will hold the number of elements that matches the query. However, it is returned an invalid generator.

OS: Debian9
Python: 3.5.3
Pymdict: 0.0.2

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.