There are various theories as to why gender has an influence in lessons
Having more girls in a primary school classroom reduces boys' attainment in English but raises their maths and science scores, research has found.
A study by Steven Proud of Bristol University analysed the national test and exam results of every state school in England between 2002 and 2004.
He says it may be beneficial to teach boys English in single sex classes.
In maths and science the findings are more complex so in practice a mix of genders is probably the best policy.
Mr Proud's paper, Girl Power? An analysis of peer effects using exogenous changes in the gender make-up of the peer group, was presented at the Royal Economic Society's annual conference at the University of Surrey.
He looked at the effect of year-on-year changes in the proportion of pupils who were female within a school and on test and exam results at ages seven, 11, 14 and 16.
On average, girls performed much better than boys in English, but in maths and science there was little or no difference - though boys had a very slight advantage in maths, he noted.
Results are known to be tied in with other, unobserved factors such as family background and neighbourhood affluence.
So he also took into account simple "value added" scores within each subject - the progress children made between one assessment and another.
And he filtered out schools in areas where more than 10% of pupils are selected for secondary schooling by academic ability.
The size of the schools seemed to make a difference.
In the large schools, the negative effects for boys in English disappeared, but apparent positive effects were seen in maths and science which were not seen in the small schools.
"Overall, the results imply that in primary schools at least, boys would benefit greatly from being taught English in single sex classes, which would have little effect on girls' outcomes, whilst in maths and science, different policies would benefit boys and girls: boys would be better off in a more female classroom, whilst girls would be better off in an all female classroom.
"However, it is not possible to increase the proportion of girls for both boys and girls, implying that a mix of the genders is optimal in both maths and science."
Mr Proud's work adds to the sometimes contradictory body of research on the effect of gender in schooling - including the effects of single-sex classes and single-sex schools.
He speculates that there are a couple of possible mechanisms for the boys' poor results in English when there are many girls around.
One is that the boys are being "crowded out" - being left behind or hiding in the background.
Or girls and boys might have different learning styles - so having lots of girls means boys are getting unsuitable teaching.
The old argument that boys tend to be more disruptive in lessons might explain the maths and science findings - that both boys and girls do better if there are fewer boys or more girls.
The data used in the study are at least five years old. In England schools now have a statutory "gender equality duty" to tackle relative underachievement by boys or girls.