hello,\t do[100000;a[0]]23\t do[100000;first a]13
Guessing first doesn’t do any pointer arithmetic eg. *ptr .. whereasindexing does *(ptr+0)Mohammad NoorOn Jun 6, 9:40?pm, James Lee <james.adams…> wrote:> hello,> \t do[100000;a[0]]> 23>> \t do[100000;first a]> 13</james.adams…>
last is also faster than either indexing or first reverse. presumably
it’s *(ptr+n)
To: personal-kdbplus@googlegroups.com
X-Mailer: Apple Mail (2.1084)
it is the bytecode
q)first value{first l}
0x81230002
q)first value{l 0}
0x0c81520002
Attila
On 7 Jun 2011, at 00:14, Aaron Davies wrote:
> last is also faster than either indexing or first reverse. presumably
> it’s *(ptr+n)
>
> On Monday, June 6, 2011, Mohammad Noor wrote:
>> Guessing first doesn’t do any pointer arithmetic eg. *ptr .. whereas
>> indexing does *(ptr+0)
>>
>> Mohammad Noor
>>
>> On Jun 6, 9:40 pm, James Lee <james.adams…> wrote:
>>> hello,
>>> \t do[100000;a[0]]
>>> 23
>>>
>>> \t do[100000;first a]
>>> 13
>>
>> –
>> You received this message because you are subscribed to the Google =
Groups “Kdb+ Personal Developers” group.
>> To post to this group, send email to =
personal-kdbplus@googlegroups.com.
>> To unsubscribe from this group, send email to =
personal-kdbplus+unsubscribe@googlegroups.com.
>> For more options, visit this group at =
http://groups.google.com/group/personal-kdbplus?hl=en.
>>
>>
>
> –
> Aaron Davies
> aaron.davies@gmail.com
>
> –
> You received this message because you are subscribed to the Google =
Groups “Kdb+ Personal Developers” group.
> To post to this group, send email to =
personal-kdbplus@googlegroups.com.
> To unsubscribe from this group, send email to =
personal-kdbplus+unsubscribe@googlegroups.com.
> For more options, visit this group at =
http://groups.google.com/group/personal-kdbplus?hl=en.
>
</james.adams…>
> it is the bytecode>> q)first value{first l}> 0x81230002> q)first value{l 0}> 0x0c81520002Yep. It appears that {l 0} is compiled as a binary function call,probably using @ as the operator. Compare the bytecode for {l 0} tothe code for {l@0} and and related expressions:q)first value {l 0}0x0c81520002q)first value {l@0}0x0c81520003q)first value {l@l}0x8181520003q)first value {0@0}0x0c0c520003Looks like “push push call return”, with twice as much stack andreference counting activity as {first l}.
The bytecode is a bit of a red herring.
The example
\t do[100000;first a]
is not compiling anything, and hence there is no byte code to
interpret; it is just interpreting the parse tree.
x[y] does more work simply because it has more things to check; is x a
function, dict, table, list, is y a scalar/list.