Vote tallying...

Andrew Robinson andrew3 at r3dsolutions.com
Fri Jan 18 00:59:41 CET 2013


Hi,

I have a problem which may fit in a mysql database, but which I only 
have python as an alternate tool to solve... so I'd like to hear some 
opinions...

I'm building a experimental content management program on a standard 
Linux Web server.
And I'm needing to keep track of archived votes and their voters -- for 
years.

Periodically, a python program could be given a batch of new votes 
removed from the database, and some associated comments, which are no 
longer real-time necessary;  and then a python script needs to take that 
batch of votes, and apply them to an appropriate archive file.  It's 
important to note that it won't just be appending new votes, it will be 
sorting through a list of 10's of thousands of votes, and changing a 
*few* of them, and appending the rest.

XML may not be the ideal solution, but I am easily able to see how it 
might work.  I imagine a file like the following might be inefficient, 
but capable of solving the problem:

<?xml version="1.0"?>
<data>

    <identify>
        <contentid>12345A3</contentid>
        <authorid>FF734B5D</authorid>
        <permissions>7FBED</permissions>
        <chapter>The woodstock games</chapter>
     </identify>

     <comments>
         <comment id="FF53524" date="2013.01.12">I think you're on 
drugs, man.!</comment>
         <comment id="unregistered" date="2013.01.12">It would have been 
better if they didn't wake up in the morning.</comment>
     </comments>

     <votes>
         <v id="FF3424">10</v>
         <v id="F713A4">1</v>
         <v id="12312234">3</v>
     </votes>
</data>

The questions I have are, is using XML for vote recording going to be 
slow compared to other stock solutions that Python may have to offer?  
The voter ID's are unique, 32 bits long, and the votes are only from 1 
to 10. (4 bits.).  I'm free to use any import that comes with python 
2.5. so if there's something better than XML, I'm interested.

And secondly, how likely is this to still work once the vote count 
reaches 10 million?
Is an XML file with millions of entries something someone has already 
tried succesfully?





More information about the Python-list mailing list