lundi 23 mars 2015

Add file paths to database


I am scanning a directory of files and want to add them to a database. I have two variants:



for file in walk(basedir):
files.append(file)
for file in files:
add_to_database(file)


versus



for file in walk(basedir):
add_to_database(file)


The former has the advantage that if both the database and the scanned dir reside on the same physical disk, jumping between two locations on disk (assuming spindels) is avoided and thus should be faster, at the cost of additional memory consumption.


The latter is much shorter. I am tending towards the latter, adding a note that the database should not reside on the same disk as the scanned dir.


Any thoughts on this?





Aucun commentaire:

Enregistrer un commentaire