python - Get the index of an element in a queryset -


I have a QuerySet, let's call it qs , which is sorted by some attribute Which is irrelevant for this problem then I have an object, let's call it obj . Now I want to know which index is obj in qs , as efficiently is possible as possible. I know that I can use each object from obj with .index () from Python or possibly loop through qs But what is the best way to go about doing this? I am looking for high performance and this is my criteria.

Use Python 2.6.2 with Windows Django 1.0.2.

There is no shortcut to get an indicator of such elements , And I think that a simple walk is the best way to do this.

For the starter, I would like to implement your requirement in the simplest way (eg, etching); Problems are there, then I have a few different approaches to sub I will do this, like creating a query with small areas, or whatever.
In any situation, it is a thought that leave such tricks as much as possible, when you certainly know that You need them.
Update: You can directly use some SQL statement which is called Ronnambar (to get some lies). However, Origen of Origen of Django Not done and your View used to raw SQL query (it). I think that given the be the best choice, but again - if you actually issue an actual performance.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -