MongoEngine 0.8 RC4 Released

27 views
Skip to first unread message

Ross Lawley

unread,
May 10, 2013, 11:22:46 AM5/10/13
to mongoeng...@googlegroups.com, mongoen...@googlegroups.com
MongoEngine 0.8.0RC4 has been released.

A tricky issue meant that I had to look to do more refactoring to querysets - see: https://github.com/MongoEngine/mongoengine/issues/311

The upshot is we now cache the resultset of the query and we have reintroduced __len__ (which no longer calls .count() underneath as it did in 0.7.10).  The most common use of len(queryset) is implicit when converting it to a list - eg list(queryset).  

So len(queryset) now it iterates the resultset and populates the cache.  As such the following now only requires one query:

for doc in queryset:
    print doc.name
len(queryset)
for doc in queryset:
    print doc.name
queryset.count()

Previously that would have been 4 - there is some caching also when calling count()

 If you ever used len(queryset)instead of queryset.count()and you dont iterate the whole queryset then you should update your code!

Take RC4 out for a drive and hopefully 0.8.0 final will be RC4.

Ross



On Tue, May 7, 2013 at 1:31 PM, Ross Lawley <ross....@gmail.com> wrote:
MongoEngine 0.8.0RC3 has been released - a few fixes over the original RC

Aiming for final at end of the week!


On Wed, May 1, 2013 at 3:25 PM, dorian i <dorian...@gmail.com> wrote:
This broke flask_mongoengine :(

https://github.com/MongoEngine/flask-mongoengine/issues/42


On Wednesday, May 1, 2013 12:13:27 PM UTC+2, Rozza wrote:
Hi all,

MongoEngine 0.8 RC1 has been released today!


So please tweet and promote ;)

As ever the documentation (http://docs.mongoengine.org) has all the information;  changelogs and upgrade paths but any questions please don't hesitate to ask.

Cheers,

Ross

--
You received this message because you are subscribed to the Google Groups "MongoEngine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongoengine-us...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 


Roy Smith

unread,
May 10, 2013, 1:57:52 PM5/10/13
to mongoeng...@googlegroups.com
On May 10, 2013, at 11:22 AM, Ross Lawley wrote:

MongoEngine 0.8.0RC4 has been released.

A tricky issue meant that I had to look to do more refactoring to querysets - see: https://github.com/MongoEngine/mongoengine/issues/311

The upshot is we now cache the resultset of the query and we have reintroduced __len__ (which no longer calls .count() underneath as it did in 0.7.10).  The most common use of len(queryset) is implicit when converting it to a list - eg list(queryset).  

So len(queryset) now it iterates the resultset and populates the cache.  As such the following now only requires one query:

for doc in queryset:
    print doc.name
len(queryset)
for doc in queryset:
    print doc.name
queryset.count()

What triggers the caching?  Is it the calling len(), or the actual iteration.  Specifically, if I do:

for doc in MyDocumentClass.objects():
whatever()

is it going to cache a copy of every object?  That could be a very large amount of data.


--
Roy Smith

Ross Lawley

unread,
May 10, 2013, 2:16:58 PM5/10/13
to mongoeng...@googlegroups.com
It seemed the nicest way round the various issues the queryset was facing, I could add a non caching queryset if that's of interest.

I followed djangos model, in that it caches on calling len() but if you don't call len() it does cache on iteration.  The side effect is it will increase memory usage, but seems a tried and tested approach.

Ross

Diego Woitasen

unread,
May 15, 2013, 5:16:45 PM5/15/13
to mongoeng...@googlegroups.com, mongoen...@googlegroups.com
Nice work, it's working fine!
Reply all
Reply to author
Forward
0 new messages