Django form widgets and performance
I was wondering (maybe it's a silly tought too) if there's any difference in performance (such as response time, memory usage) between the various django widgets for forms...
I have a pre-designed template, which i cannot modify, so t开发者_如何转开发here's not form.as_p for me. So, since i grab every value as it is, without checking what type it's in the html form (checkbox, radio, input etc...) i tought i could use the same form widget in django's form.py for every field, if there's a field that is better than the others...
Any idea, or is just a silly question because i'm tired?
Sounds pretty silly IMO. Likely the difference in performance between the forms fields is a tiny fraction of a %. Obviously the regex based ones would likely be a tiny be slower. So to answer your question you are well into the territory of premature optimization and there be demons over that hill. Use fields that make sense.
If you are really concerned then I suggest you benchmark it yourself with the shell. Devise a script that fills a form with random (valid) values a few thousand times and see if there is a measurable difference.
精彩评论