On 8/07/19 2:48 AM, Alan Gauld via Tutor wrote:
On 07/07/2019 09:19, David L Neil wrote:
First-off, it has to be said that "100's of elements" suggests using an
RDBMS - particularly if 'age' (eg 23 and 99) is not the only likely
selection mechanism.

Multiple selection mechanisms might suggest an RDBMS but hundreds of
items is chickenfeed and an RDBMS would be overkill for such small
numbers, if volume was the only criteria. Millions of items would
certainly warrant such an approach but nowadays holding 10's of
thousands of items in memory is entirely reasonable.


Assuming plentiful RAM: agreed.
(However, some of us grew-up at a time when RAM was expensive and even in our relaxed state, such 'costs' still impinge on our consciousness - also, in another thread (here?Python list) we had someone frustrated about using an MS-Vista 'powered' machine and limited to 32-bits. We don't know the OP's circumstances. That said, loading an RDBMS, if (s)he doesn't already have one, is...)

As you point-out, with memory more-commonly available, I've obtained significant speed improvements by moving relatively small, and particularly temporary, DB tables into MySQL's MEMORY storage (and with almost zero code-change/risk)!
(so, it IS possible to teach old dogs new tricks)


The key justification for moving to RDBMS would be "not the only selection mechanism". Whereas a Python dictionary (hash) offers speedy access to data based upon a single index, it is hard to beat the bug- and time-saving facility of a DB managing multiple indices/indexes. (appreciating that I have no difficulty moving from (Python) procedural programming to (SQL) declarative, but many of our colleagues hate such, and with a passion)


So, using the OP's data-example, and assuming the 'columns' to be perhaps employment_date, name, and age; respectively:

['2019-01-19','Fred Flintstone',23],
['2019-02-01','Scooby doo', 99]

- which Python (and pythonic - per OP's theme) structures and methods offer a relatively bug-unlikely solution to holding *multiple* indices into a base list (or other collection)? (alternately, maybe we should wait for the OP, and allow opportunity to complete the homework first?)

(NB this may be veering OT, if the OP requires only the single access method, such as that illustrated earlier)
--
Regards =dn
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to