On 29 syys, 21:51, Shai Berger <s...@platonix.com> wrote: > On Sunday 23 September 2012, Anssi Kääriäinen wrote:> On 22 syys, 23:34, Shai > Berger <s...@platonix.com> wrote: > > There isn't much time to do feature additions. It is possible to get > > the feature into 1.5, but you should not expect it to happen. As for > > the feature itself, I am not yet sure if it is a good idea or not. The > > basic problem is granularity: wouldn't you want to do this per query, > > or even per expression basis? > > No, I don't; the issue is cross-database compatibility. We have raw SQL > statements calculating some expressions, and then use the returned values in > calculations in Python -- adding and muliplying them with floats. This worked > fine with MySql and the 3rd-party SQL Server backends, but blew up on Oracle > because Decimals and floats don't mix very well:
The problem seems to be that on Oracle, 1.1 is NUMERIC, and that is something which _is_ a decimal in Python. We should not change that. To me it seems the answer is to use to_binary_float/to_binary_double in raw SQL queries. For example: cur = connection.cursor() cur.execute("select count(*) from tests_place") print cur.fetchone()[0] vals = None def do_query(): global vals cur.execute("select 1.1 from tests_place") vals = [val[0] for val in cur.fetchall()] t = Timer('do_query()', 'from __main__ import do_query') print t.timeit(number=20) print type(vals[0]) OUT: 2000 0.719314813614 <class 'decimal.Decimal'> Replace the query with "select to_binary_double(1.1) from tests_place": OUT: 2000 0.337587118149 <type 'float'> Based on the above I am -1 on having a flag that interprets NUMBER fields as floats. There is already an Oracle data type to use for this. I tested the pull request 393 (the speedup to ._rowfactory). Above test case, and the decimal case runs in around one second, the float case in 0.1 seconds. So, there is a regressions for decimals. On the other hand floats are way faster. Will investigate... As for new features for 1.5: there is roughly a day before feature freeze. Getting any new ticket into 1.5 is really unlikely at this point, existing pull requests have priority. - Anssi -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.